Details

    • Similar Issues:
    • Sprint:
      Declarative backlog

      Description

      This issue is based on JENKINS-45455 which solves the issue of restarting a Jenkins Pipeline from Top-Level stages.

      Description
      When building on multiple platforms, the builds are usually ran in parallel. We should be able to replay the build of a single platform. (e.g. if the Win64 build fails, we do not want to retrigger the already successful Macos and Linux builds)
      In a multiplatform build pipeline, the steps taking the most time are the "build" steps themselves and they are running in parallel to get fast build times. Restarting from a top level in that context boils down to re-running the whole job.

      Use cases

      • Restarting a Jenkins Pipeline from a sub-stage or parallel stage
      • Given the following graph, we should be able to replay from any stage (e.g. Build-Win64, Test-MacOs, Deploy) :
        Build-Win64 -> Test-Win64 -| 
        Build-Win32 -> Test-Win32 -|-> Deploy
        Build-MacOS -> Test-MacOS -|
        Build-Linux -> Test-Linux -|

         

        Attachments

          Issue Links

            Activity

            Hide
            kadam Adam Kapos added a comment -

            We'd love to see support for this. Are there any known workarounds that would allow us to make this work, other than creating a separate pipeline for each parallel branch?

            Show
            kadam Adam Kapos added a comment - We'd love to see support for this. Are there any known workarounds that would allow us to make this work, other than creating a separate pipeline for each parallel branch?
            Hide
            gabih Gabriel Herisanu added a comment - - edited

            You can use something like this:

            #!groovy
            def withCheck(String blockName, Closure closure) {
                script {
                    def buildStage = true
                    catchError(message: 'check previous build status', stageResult:'SUCCESS', buildResult: 'SUCCESS') {
                        unstash name:"${blockName}"
                        buildStage = false
                    }
            
                    if (buildStage) {
                        closure.call()
                        writeFile file: "${blockName}", text: "1"
                        stash name: "${blockName}", includes: "${blockName}"
                    }
                }
            }
            
            pipeline {
                agent none
            
                options {
                    preserveStashes()
                }
            
                stages {
                    stage("Build and test") {
                        parallel() {
                            stage("Build/Test Win64") {
                                agent {
                                    label 'master'
                                }
                                steps {
                                    withCheck("build-deploy-Win64") {
                                        echo "test"
                                    }
            
                                    withCheck("test-Win64") {
                                        echo "test"
                                    }
                                }
                            }
            
                            stage("Build/Test Win32") {
                                agent {
                                    label 'master'
                                }
                                steps {
                                    withCheck("build-deploy-Win32") {
                                        echo "test"
                                    }
            
                                    withCheck("test-Win32") {
                                        echo "test"
                                    }
                                }
                            }
                        }
                    }
            
                    stage("Deploy") {
                        agent {
                            label 'master'
                        }
                        steps {
                            withCheck("build-deploy-win64") {
                                echo "test"
                            }
            
                            withCheck("test-win64") {
                                echo "test"
                            }
                        }
                    }
                }
            }
            

             

            Show
            gabih Gabriel Herisanu added a comment - - edited You can use something like this: #!groovy def withCheck( String blockName, Closure closure) { script { def buildStage = true catchError(message: 'check previous build status' , stageResult: 'SUCCESS' , buildResult: 'SUCCESS' ) { unstash name: "${blockName}" buildStage = false } if (buildStage) { closure.call() writeFile file: "${blockName}" , text: "1" stash name: "${blockName}" , includes: "${blockName}" } } } pipeline { agent none options { preserveStashes() } stages { stage( "Build and test" ) { parallel() { stage( "Build/Test Win64" ) { agent { label 'master' } steps { withCheck( "build-deploy-Win64" ) { echo "test" } withCheck( "test-Win64" ) { echo "test" } } } stage( "Build/Test Win32" ) { agent { label 'master' } steps { withCheck( "build-deploy-Win32" ) { echo "test" } withCheck( "test-Win32" ) { echo "test" } } } } } stage( "Deploy" ) { agent { label 'master' } steps { withCheck( "build-deploy-win64" ) { echo "test" } withCheck( "test-win64" ) { echo "test" } } } } }  
            Hide
            wohali Joan Touzet added a comment -

            Gabriel Herisanu This bug is about declarative language features - see the Epic Link and Sprint tagging above.

            Your suggestion isn't declarative.

            Show
            wohali Joan Touzet added a comment - Gabriel Herisanu This bug is about declarative language features - see the Epic Link and Sprint tagging above. Your suggestion isn't declarative.

              People

              • Assignee:
                Unassigned
                Reporter:
                franknarf8_ni Frank Genois
              • Votes:
                42 Vote for this issue
                Watchers:
                27 Start watching this issue

                Dates

                • Created:
                  Updated: