Tuffwer
Tuffwer

Reputation: 1047

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

Upvotes: 1

Views: 2715

Answers (1)

Dima Nevelev
Dima Nevelev

Reputation: 408

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/"
}

Upvotes: 4

Related Questions