Jenkins管道错误 - 未知阶段部分“sh”和阶段中的步骤必须在步骤块中

时间:2018-06-05 14:30:40

标签: jenkins jenkins-pipeline

我有一些与此几乎相同的东西,它工作正常,现在我得到以下错误。我在那里parallelstepsstages

错误:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 23: Unknown stage section "sh". Starting with version 0.5, steps in a stage must be in a steps block. @ line 23, column 7.
         stage('build api image') {
         ^

WorkflowScript: 26: Unknown stage section "sh". Starting with version 0.5, steps in a stage must be in a steps block. @ line 26, column 7.
         stage('build view image') {
         ^

WorkflowScript: 20: No "steps" or "parallel" to execute within stage "gradle test" @ line 20, column 7.
         stage('gradle test') {
         ^

WorkflowScript: 23: No "steps" or "parallel" to execute within stage "build api image" @ line 23, column 7.
         stage('build api image') {
         ^

WorkflowScript: 26: No "steps" or "parallel" to execute within stage "build view image" @ line 26, column 7.
         stage('build view image') {

pipeline {
    agent any

    stages {
      stage('run test cases in modules') {
            steps {
              parallel(
              "Gradle clean": {
                  sh "./gradlew clean"
               },
                "api-service-tests": {
                  sh "./gradlew api:test"
                },
                "cache-api-tests": {
                  sh "./gradlew view:test"
                }
              )
            }
      }
      stage('gradle test') {
            // sh "./gradlew --no-daemon test"
      }
      stage('build api image') {
            sh "oc start-build cms-api --from-dir=api/docker --follow"
      }
      stage('build view image') {
            sh "oc start-build  --from-dir=view --follow"
      }
    }

}

1 个答案:

答案 0 :(得分:1)

您缺少其他阶段指令中的steps指令。

stage('gradle test') {
  // sh "./gradlew --no-daemon test"
}

应该更像是:

stage('gradle test') {
  steps {
    sh "./gradlew --no-daemon test"
  }
}