How to continue past a failing stage in Jenkins declarative pipeline syntax

后端 未结 4 485
深忆病人
深忆病人 2021-02-01 06:14

I want to define multiple stages in Jenkins declarative pipeline syntax which can continue past any one of them failing. I cannot find any existing questions which are true dupl

4条回答
  •  庸人自扰
    2021-02-01 06:38

    I may be missing something, but the idea of declarative, opinionated pipeline is to provide coverage of most simple use cases. The moment you need something the opinionated hasn't covered, you HAVE to resort to scripted pipeline, this is only referring to the "requirement" of "declarative pipeline": not going to happen now.

    As to your other "requirements", they make very little sense, since the whole idea is to wrap low-level ugliness into shared libraries providing users with constructs like:

        mylib.failable_stages({
          stages {
            stage('stage 1') {
              steps {
                echo "I need to run every time"
              }
            }
            stage('stage 2') {
              steps {
                echo "I need to run every time, even if stage 1 fails"
              }
            }
            stage('stage 3') {
              steps {
                echo "Bonus points if the solution is robust enough to allow me to continue *or* be halted based on previous stage status"
              }
            }
          }
        })
    

    Naturally, you would have to find or implement such mylib class and the failable_stages would get a closure, and wrap it in various plumbing/boilerplate code pieces.

    Hope this is helpful.

提交回复
热议问题