2017-04-04 126 views
6

这是我试图执行的Jenkins管道。我正在关注this tutorialJenkins与平行管道

pipeline { 
    agent any 
    stages { 
     stage('one') { 
      parallel "first" : {    
        echo "hello"     
      }, 
      "second": {     
        echo "world"    
      } 
     } 
     stage('two') { 
      parallel "first" : {    
        echo "hello"     
      }, 
      "second": {     
        echo "world"    
      } 
     } 
    } 
} 

但是,作业失败并显示以下消息。

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed: 
WorkflowScript: 4: Unknown stage section "parallel". Starting with version 0.5, steps in a stage must be in a steps block. @ line 4, column 9. 
      stage('one') { 
     ^

WorkflowScript: 12: Unknown stage section "parallel". Starting with version 0.5, steps in a stage must be in a steps block. @ line 12, column 9. 
      stage('two') { 
     ^

WorkflowScript: 4: Nothing to execute within stage "one" @ line 4, column 9. 
      stage('one') { 
     ^

WorkflowScript: 12: Nothing to execute within stage "two" @ line 12, column 9. 
      stage('two') { 
     ^

4 errors 

有人可以帮我解答为什么这是失败的。

回答

14

您需要在舞台声明后添加步骤块。

pipeline { 
    agent any 
    stages { 
     stage('one') { 
      steps { 
       parallel("first": { 
        echo "hello" 
       }, 
         "second": { 
          echo "world" 
         } 
       ) 
      } 
     } 
     stage('two') { 
      steps { 
       parallel("first": { 
        echo "hello" 
       }, 
         "second": { 
          echo "world" 
         } 
       ) 
      } 
     } 
    } 
} 
+0

非常感谢你,它的工作 – Shahzeb

+1

但这使步骤平行,而不是阶段。无论如何,我还没有找到更好的解决方案。 –