How to create folders dynamically and upload artif

2019-07-18 05:41发布

问题:

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:

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.