【问题标题】:How to to pass pipeline parameter to shell script如何将管道参数传递给shell脚本
【发布时间】:2019-11-06 04:35:28
【问题描述】:

我有一个 groovy 文件,我需要在 shell 脚本中使用管道参数:

def call() {
    echo "current build number: ${currentBuild.number}"
    def pipelineValue = "${currentBuild.number}"
    sh '''
        cd /jenkins/jenkins/workspace/Run_Distribution_Self_Service/
        mkdir -p builds/{pipelineValue }/libs/jfrog_distribution_shared_lib/resources/com/amdocs/python_distribution_util
'''

如何在 shell 脚本中获取 pipelineValue 并使用它?

【问题讨论】:

标签: shell groovy jenkins-pipeline


【解决方案1】:

正确的语法:

mkdir -p builds/'''+pipelineValue+'''/libs/jfrog_distribution_shared_lib/resources/com/amdocs/python_distribution_util

以下链接帮助了我: Pass groovy variable to shell script

【讨论】:

    【解决方案2】:
    def call() {
    echo "current build number: ${currentBuild.number}"
    def pipelineValue = "${currentBuild.number}"
    sh '''
        cd /jenkins/jenkins/workspace/Run_Distribution_Self_Service/
        mkdir -p builds/${pipelineValue}/libs/jfrog_distribution_shared_lib/resources/com/amdocs/python_distribution_util
    '''
    

    【讨论】:

      猜你喜欢
      • 2016-07-03
      • 1970-01-01
      • 1970-01-01
      • 2012-12-08
      • 1970-01-01
      • 2021-04-16
      • 2019-09-29
      • 2021-01-11
      • 1970-01-01
      相关资源
      最近更新 更多