Jenkins Pipeline Get Current Stage Status After Using catchError

前端 未结 4 1618
孤独总比滥情好
孤独总比滥情好 2021-01-19 05:39

This is a follow-up to my earlier question:

Set a stage status in Jenkins Pipelines

It turns out I can keep a pipeline as SUCCESS but can mark an individual

4条回答
  •  醉梦人生
    2021-01-19 06:20

    I did it like this (to keep the catchError):

    def boolean test_results = false
    
    pipeline {
        ...
        stage( 'x' ) {
            steps{
                catchError(buildResult: 'SUCCESS', stageResult: 'FAILURE') {
                    
                    
                    
                    //
                    // If we reached here the above step hasn't failed
                    //
                    script { test_results = true }
                }
            }
        }
        stage( 'y' ) {
            steps{
                script{
                    if( test_results == true ) {
                    } else {
                    }
                }
            }
        }
    }
    

提交回复
热议问题