Alexy Pulivelil
Alexy Pulivelil

Reputation: 177

Download artifacts from JFrog with Jenkins

I wrote a Jenkins pipeline to download the artifcats from JFrog. I have artifactory plugin for Jenkins so I use rtdownload. Below is the rtdownload section

rtDownload (
              serverId: 'pe-jfrog',
                            spec: '''{
                                "files": [
                                    {
                                    "pattern": "my-local-repo-dev/test-${buildVersion}.tar"

                                    }
                                ]
                            }''',

                            buildName: 'my-test-build',
                            buildNumber: "${env.buildVersion}"
                        )

I use choice parameter to get buildversion. With this I'm able to download.

Now my requirement is how can I pass the value to pattern

I decalred variable as def jfrogrepo = "my-local-repo/test-${buildVersion}.tar"

I tried to call this variable as

None of it works.But on echoing the variable I'm getting correct output.

So is there a way to pass variable to pattern or is there any other way to download the artifacts by making use of the artifacory plugin.

Upvotes: 0

Views: 1204

Answers (2)

Amirhossein Taheri
Amirhossein Taheri

Reputation: 231

Why don't you use the CLI of JFrog for Jenkins? you can use Jfrog plugin for your purpose and after that you can add JFrog CLI as tools in JFrog artifactory, then you can use this command in Jenkinsfile and pipeline:

jf "rt dl my-local-repo/cool-froggy.zip"

Upvotes: 0

Ruslan
Ruslan

Reputation: 605

rtDownload (
  serverId: 'pe-jfrog',
  spec: """{
    "files": [
      {
        "pattern": "my-local-repo-dev/test-${env.buildVersion}.tar"
      }
    ]
  }""",
  buildName: 'my-test-build',
  buildNumber: "${env.buildVersion}"
)

there is difference in groovy for single/double quotes

i like this page

https://gist.github.com/Faheetah/e11bd0315c34ed32e681616e41279ef4

in quick

in single quotes variables will not be interpolated/evaluated. ${} this will not work

in double quotes vars ${} evaluated to actual value

FYI

env. its global variable for jenkins pipeline treated as environment variable in sh script and global variable for jenkinsfile part of currentbuild object

parameters in pipeline used as ${params.VARIABLE} see this

Upvotes: 0

Related Questions