jenkins 这个舞台没有台阶蓝海

cbwuti44  于 2023-04-05  发布在  Jenkins
关注(0)|答案(1)|浏览(222)

我正在用蓝海创建一个Jenkins管道。
现在我尝试向流添加SonarQube分析。但是当我运行流时,它说:
无步骤此阶段无步骤
舞台看起来像:

stage('Analysis') {
      steps {
        script {
          if (env.BRANCH_NAME == 'develop') {
            withSonarQubeEnv('SonarQube Server') {
              bat 'mvn sonar:sonar'
              def qualitygate = waitForQualityGate()
              if (qualitygate.status != "OK") {
                error "Pipeline aborted due to quality gate coverage failure: ${qualitygate.status}"
              }
            }
          }
        }

      }
    }

流程正在develop分支中运行:

我不知道为什么Jenkins说这个错误。有人可以帮助我吗?

eqqqjvef

eqqqjvef1#

将我的流程更改为使用when关键字:

stage('SonarQube analysis') { 
  when {
    branch 'develop'
  }
  steps {
    withSonarQubeEnv('SonarQube') { 
      bat 'mvn sonar:sonar'
    }
  }
}
stage("SonarQube Quality Gate") { 
  when {
    branch 'develop'
  }
  steps {
    timeout(time: 10, unit: 'MINUTES') { 
      script {
        sleep 120
        def qg = waitForQualityGate() 
        if (qg.status != 'OK') {
          error "Pipeline aborted due to quality gate failure: ${qg.status}"
        }
      }
    }
  }
}

相关问题