Reputation: 3863
I have a Jenkins job which generate a zip file I want to updload to Artifactory. I have an issue setting the version of the artifact to be uploaded.
By convention, I use the timestamp has version. I want to upload file to my/group/timestamp/file.zip
. The url of the file would be http://ArtifactoryAdress/foo/my/group/timestamp/file.zip
Here is my pipeline code
def serverArtifactory = Artifactory.server 'NameArtificatory'
def uploadSpec = """{
"files": [
{
"pattern": "file.zip",
"target": "my/group/${timestamp}/"
}
]
}"""
serverArtifactory.upload(uploadSpec)
I get the following error from Jenkins Job
java.lang.RuntimeException: java.io.IOException: Failed to deploy file. Status code: 400 Response message: Artifactory returned the following errors: Parent my/group/timestampValue must be a folder Status code: 400
I looked around buildInfo but was not able to find how to set a version.
By the way, I am also agree with a solution without the timestamp but only group name.
Upvotes: 1
Views: 7776
Reputation: 3863
Finally, this error is clear and simple.
As mentioned, a file with path my/group/timestampValue
already exists. You have to delete it on Artifactory.
Upvotes: 2
Reputation: 890
Don't forget it's still groovy use ${}
. I used below code and it's work
def uploadSpec = """{
"files": [
{
"pattern": "**/target/*.war",
"target": "local-release/${APP_REPO}/${version.trim()}/${timestamp}.zip"
}
]}"""
server.upload(uploadSpec)
@Edit. And I just thought about it. Print please your ${timestamp}
. Maybe it's contains characters with spaces, or something like this which Artifactory not allowed in directory name. Try trim your timestamp.trim()
Upvotes: 0