简体   繁体   English

Jenkins 访问下游作业中的参数

[英]Jenkins Access to the params in downstream job

I sent params to the downstream job like this:我像这样将参数发送到下游作业:

build job: '../UItest/master', parameters: [
        string(name: 'parent_branch', value: String.valueOf(BRANCH_NAME)),
        string(name: 'parent_build', value: String.valueOf(BUILD_NUMBER))
      ], wait: false

Then in downstream when I try to access it like:然后在下游,当我尝试访问它时:

sh '''
    echo ${params.parent_branch}
    '''

it throws me this error: ${params.parent_branch}: bad substitution它向我抛出此错误: ${params.parent_branch}: bad substitution

but I can access to it like:但我可以像这样访问它:

sh "echo ${params.parent_branch}"

and it works fine.它工作正常。

so what is differences between ''' and " in running shell script and using params?那么在运行 shell 脚本和使用参数时'''"之间有什么区别?

Thanks谢谢

I got my answer, it is described here: https://groovy-lang.org/syntax.html我得到了答案,这里有描述: https : //groovy-lang.org/syntax.html

Triple-single-quoted '''...''' doesn't support interpolation to use variables like that.三重单引号 '''...''' 不支持插值来使用这样的变量。 We should use Triple-double-quoted """…​""" instead我们应该使用三重双引号 """...""" 代替

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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