3
votes

I have a build job in jenkins which builds the project from github for any branch. package will be created in build job workspace with the version as xxxx-yyyyy-2.15.0-SNAPSHOT.zip.

My next artifactory push job has filespec written as below:

{ 
 "files": [
       {
           "pattern": "/var/lib/jenkins/workspace/Jobname/target/*/xxxx-yyyyy*.zip",
           "target": "libs-snapshot-local/xxxx-yyyyy/",
           "recursive": "false"
       }
    ]
}

Above filespec recognize the pattern and upload the zip in libs-snapshot-local/xxxx-yyyyy/. But I need to upload the file with folder created with version name available on the zip file xxxx-yyyyy-2.15.0-SNAPSHOT.zip.

Can anybody help me to create a folder dynamically with version name? any idea on how to specify target path in filespec?

1

1 Answers

6
votes

The file specs has the ability to use placeholders in order to create more flexible paths.
For example in your case:

{ 
 "files": [
       {
           "pattern": "/var/lib/jenkins/workspace/Jobname/target/*/(xxxx-yyyyy*).zip",
           "target": "libs-snapshot-local/{1}/",
           "recursive": "false"
       }
    ]
}

Please pay attention for the parentheses in the pattern and the placeholder marker {1} used in the target.