简体   繁体   中英

Use the Artifactory Plugin in Jenkins to conditionally download files from artifactory

How can I choose a different download spec for the Jenkins Artifactory plugin based on the value of a build job string parameter?

For a given value of the string parameter I want to download a folder from artifactory, and for a different value of the string parameter I want to download a different folder from artifactory.

I'm trying to get these folders directly from artifactory because they contain build output from a different project that my build needs to use and change frequently, I can't just check them into the SCM for my build, but must have the current versions at build time.

I've looked at the pages for the Jenkins Artifactory Plugin and at the Jfrog Artifactory user guide but I haven't found anything on how to do this using the plugin.

I'm using a freestyle build with the Generic-Artifactory Integration option.

Jenkins version: 1.651.3
Artifactory Plugin Version: 2.8.1
Artifactory Version 4.6.1

You can use environment variables in both the spec path and the spec content.

In your case, you can upload to your SCM a spec for each job with the job name in the path. Then, you can dynamically set the spec file path using environment variable as shown below: specFilePath

Another way is to set a variable (for example PATTERN-PATH) in each job and use it in the spec.

{
  "pattern": "libs-snapshot-local/${PATTERN-PATH}/*",
  "target": "out/downloaded/"
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM