How to wait for user input in a Declarative Pipeline without blocking a heavyweight executor

前端 未结 5 817
执念已碎
执念已碎 2021-02-05 03:25

I\'m rebuilding an existing build pipeline as a jenkins declarative pipeline (multi-branch-pipeline) and have a problem handling build propagation.

After packaging and s

5条回答
  •  孤城傲影
    2021-02-05 03:43

    Another way to do it is using the expression directive and beforeAgent, which skips the "decide" step and avoids messing with the "env" global:

    pipeline {
        agent none
    
        stages {
            stage('Tag on Docker Hub') {
                when {
                    expression {
                        input message: 'Tag on Docker Hub?'
                        // if input is Aborted, the whole build will fail, otherwise
                        // we must return true to continue
                        return true
                    }
                    beforeAgent true
                }
    
                agent { label 'yona' }
    
                steps {
                    ...
                }
            }
        }
    }
    

提交回复
热议问题