2017-04-10 1 views
1

게시 단계에서 병렬 조치를 시도했지만 작동하지 않습니다.게시 실패 JenkinsFile이 작동하지 않습니다.

이 내 JenkinsFile입니다 :

pipeline { 
    agent any 

    stages { 

     stage("test") { 

      steps { 

       withMaven(
          maven: 'maven3', // Maven installation declared in the Jenkins "Global Tool Configuration" 
          mavenSettingsConfig: 'maven_id', // Maven settings.xml file defined with the Jenkins Config File Provider Plugin 
          mavenLocalRepo: '.repository') { 
           // Run the maven build 
           sh "mvn --batch-mode release:prepare -Dmaven.deploy.skip=true" --> it will always fail 
          }  
      } 
     } 

     stage("testing") { 
      steps { 
       parallel (
        phase1: { sh 'echo phase1'}, 
        phase2: { sh "echo phase2" } 
        ) 
      } 
     } 

    } 

    post { 

     failure { 

      echo "FAIL" 
     } 
    } 
} 

그러나 여기 후 장애 조치가 비트 useles입니다 ... 내가 어떤 장소를 참조하지는.

모두에게 감사드립니다! 감사합니다.

+1

나는 똑같은 문제가 있습니다! 이거 도와 줘? – Alan47

답변

3

몇 시간 동안 검색하면 문제가 발견되었습니다. 누락 된 부분은 catchError 부분입니다.

pipeline { 
    agent any 
    stages { 
     stage('Compile') { 
      steps { 
       catchError { 
        sh './gradlew compileJava --stacktrace' 
       } 
      } 
      post { 
       success { 
        echo 'Compile stage successful' 
       } 
       failure { 
        echo 'Compile stage failed' 
       } 
      } 
     } 
     /* ... other stages ... */ 
    } 
    post { 
     success { 
      echo 'whole pipeline successful' 
     } 
     failure { 
      echo 'pipeline failed, at least one step failed' 
     } 
    } 

당신은 잠재적으로 catchError 함수에 실패 할 수 있습니다 모든 단계를 마무리해야한다. ...

  • 오류가 발생하면 ...
  • 이 ... FAILUREbuild.result을 설정
  • ... 그리고 빌드

에게 계속 : 어떤이가하는 것은 마지막 포인트가 중요합니다. post{ } 블록이 호출되지 않았습니다. 전체 파이프 라인이 으로 종료 되었기 때문에이 실행되기도 전에 중단되었습니다.

+0

이 경우의 문제점은 병렬 단계입니다. 병렬이없는 일반 스테이지를 사용하는 경우. 모든 게시물 작업이 효과가 있습니다. –

+0

나를위한 것이 아닙니다. 빌드 파이프 라인에 병렬 처리가 없으며 단계 중 하나에있는 셸 스크립트가 성공적으로 실행되지 않은 경우 게시 작업이 거부되었습니다. 실제로'catchError'를 사용하여'post {}'액션의 결과를보아야했습니다. – Alan47