首页 > 其他 > 详细

parallel stage

时间:2021-08-30 06:26:59      阅读:22      评论:0      收藏:0      [点我收藏+]

declarative:

pipeline {
    agent any
   pipeline {
    agent any    
    stages {
        stage(‘Non-Parallel Stage‘) {
            steps {
                echo ‘This stage will be executed first.‘
            }
        }
        stage(‘Parallel Stage‘) {
            failFast true
            parallel {
                stage(‘并行一‘) {
                    steps {
                        echo "并行一"
                    }
                }
                stage(‘并行二‘) {
                    steps {
                        echo "并行二"
                    }
                }
                stage(‘并行三‘) {
                    stages {
                        stage(‘Nested 1‘) {
                            steps {
                                echo "In stage Nested 1 within Branch C"
                            }
                        }
                        stage(‘Nested 2‘) {
                            steps {
                                echo "In stage Nested 2 within Branch C"
                            }
                        }
                    }
                }
            }
        }
    }
}

 

 

https://blog.csdn.net/u011541946/article/details/83627600

 

parallel steps:

 

技术分享图片
pipeline {
    agent any
    stages {
        stage("parallel test") {
            steps {
                script {
                    def branches = [:]
                    MAX_CONCURRENT = 2
                    //创建fifo
                    latch = new java.util.concurrent.LinkedBlockingDeque(MAX_CONCURRENT)
                     
                    //往fifo中,填入最大个数元素
                    for(int i=0; i<MAX_CONCURRENT; i++)
                        latch.offer("$i")
                     
                    def job_list = [
                        "test1",
                        "test2",
                        "test3",
                        "test4",
                        "test5",
                        "test6"
                    ]
                     
                    for(int i=0; i<job_list.size(); i++) {
                        def name = job_list[i]
                        branches[name] = {
                            def thing = null
                            waitUntil {
                                //获取一个资源
                                thing = latch.pollFirst();
                                return thing != null;
                            }
                            try {
                                //执行job
                                build(job: name, propagate: false)
                            }
                            finally {
                                //释放一个资源
                                latch.offer(thing)
                            }        
                        }
                    }
                    timestamps {
                        parallel branches
                    }
                }
            }
        }
    }
}
View Code

 

http://www.lujun.org.cn/?p=4025

parallel stage

原文:https://www.cnblogs.com/i-shu/p/15201188.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!