2017-04-04 128 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

但這使步驟平行,而不是階段。無論如何,我還沒有找到更好的解決方案。 –