相关文章推荐
Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

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

  • "pattern" : "${jfrogrepo}"
  • "pattern" : jfrogrepo
  • 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.

    Have you tried """ instead of ''' for spec parameter? Variables inside single quotes aren't substituted. – markalex Aug 3, 2023 at 14:29

    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

    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

    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"
            

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question. Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers.

     
    推荐文章