简体   繁体   中英

How to pass jenkins parameters as array to bash script?

I want to pass in jenkins parameters as array args to my bash script.

I have tried below but no luck.

   stage('Foo Step') {
        steps {
            script {
                sh "chmod 755 runFooBar.sh"
                sh """
                    ./runFooBar.sh --baz="${params.BAZ[@]}" --bar="${params.BAR}" --foo="${params.FOO[@]}"
                """
            }
        }
    }

I am getting this error when I run above script.

 WorkflowScript: 48: unexpected token: @ @ line 48, column 75.
 ./runFooBar.sh  --baz="${params.BAZ[@]}" --bar
                                     ^

Thank you in advance.

Cheers!

Had similar issue to resolve. Try to remove the '[@]' as groovy seems not to appreciate this.

In my case it looks as follows and works thus far:

steps {
    script {
        RECIPIENTS = '"user1@domain" "user2@domain" "user3@domain"'
        sh "./send_email.sh ${RECIPIENTS}"
    }
}

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