Scripted jenkinsfile parallel stage

后端 未结 6 1622
星月不相逢
星月不相逢 2020-12-07 19:26

I am attempting to write a scripted Jenkinsfile using the groovy DSL which will have parallel steps within a set of stages.

Here is my jenkinsfile:

n         


        
6条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-07 20:00

    Here is an example from their docs:

    Parallel execution

    The example in the section above runs tests across two different platforms in a linear series. In practice, if the make check execution takes 30 minutes to complete, the "Test" stage would now take 60 minutes to complete!

    Fortunately, Pipeline has built-in functionality for executing portions of Scripted Pipeline in parallel, implemented in the aptly named parallel step.

    Refactoring the example above to use the parallel step:

    // Jenkinsfile (Scripted Pipeline)
    
    
    stage('Build') {
        /* .. snip .. */
    }
    
    stage('Test') {
        parallel linux: {
            node('linux') {
                checkout scm
                try {
                    unstash 'app'
                    sh 'make check'
                }
                finally {
                    junit '**/target/*.xml'
                }
            }
        },
        windows: {
            node('windows') {
                /* .. snip .. */
            }
        }
    }
    

提交回复
热议问题