首页 > 解决方案 > Jenkinsfile 脚本并行导致 shell 语句失败

问题描述

在我的脚本 Jenkinsfile 中,我有一行运行parallel deployments. 我省略了其他阶段和安全代码。

当我运行它时,它找不到reportUrl并且我得到错误:groovy.lang.MissingPropertyException: No such property: teamsUrl for class: groovy.lang.Binding

但是,如果我在没有parallel deployments它的情况下运行,并且我能够达到reportUrl. 我用回声语句进行了测试。有什么想法吗?

我没有正确退出并行语句吗?

stage("Deploy") {

  def deployments = [:]

  // Code here not pasted

  parallel deployments

  echo "Deployed to clusters"
}


  stage('Reporting') {
    def reportUrl = 'https://testurl'
    echo "${reportUrl}"


    sh """
      ./my-tool report deploy \
        --report-url "${reportUrl}" \
        --force
    """
  }

编辑 6/22

reportUrl 来自一个 groovy 文件:example.groovy

example = load("deploy/example.groovy")

def reportUrl = example.REPORT_URL['report']

//I can see the url being pulled correctly here

echo "${reportUrl}"

标签: jenkinsgroovyjenkins-pipelinejenkins-groovy

解决方案


推荐阅读