zoukankan      html  css  js  c++  java
  • parallel stage

    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

     scripted parallel stages:

    https://stackoverflow.com/questions/46834998/scripted-jenkinsfile-parallel-stage

    node('docker') {
        stage('unit test') {
            parallel([
                hello: {
                    echo "hello"
                },
                world: {
                    echo "world"
                }
            ])
        }
    
        stage('build') {
            def stages = [:]
    
            stages["mac"] = {
                echo "build for mac"
            }
            stages["linux"] = {
                echo "build for linux"
            }
    
            parallel(stages)
        }
    }
    

    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

    https://stackoverflow.com/questions/46834998/scripted-jenkinsfile-parallel-stage

    pipeline {
       agent {node {label "worker"}}
       stages {
          stage('Hello') {
             steps {
                script {
                    
                    def stages = [:]
                    py_env_list = ["3.6", "3.7"]
                    OS_VERSION="7.8"
                     image = docker.image("test-centos:test-latest")
                     //image.pull()
                     image.withRun("--name test_ -it  --privileged  -v ${env.WORKSPACE}:/opt/workspace") { c->
                          sh """
                              docker exec  ${c.id} bash -c '''echo 1
                              echo 2
                              echo $OS_VERSION
                              echo $SHELL
                              hostname
                              '''
                             """
                     }
    
                }
           
             }
          }
       }
    }
    

    pipeline {
       agent {node {label "231_build_worker"}}
       stages {
          stage('Hello') {
             steps {
                script {
                    
                    def stages = [:]
                    py_env_list = ["3.6", "3.7"]
                    OS_VERSION="7.8"
                     image = docker.image("10.150.9.98/sw_test/corex-centos:package-builder-7.8-latest")
                     //image.pull()
                     image.withRun("--name test_build_sw_home -it -v /root/.ssh:/root/.ssh -v /dev:/dev -v /usr/src/:/usr/src -v /lib/modules/:/lib/modules --privileged --cap-add=ALL -v ${env.WORKSPACE}:/opt/workspace") { c->
                          sh """
                              docker exec  ${c.id} bash -c '''echo 1
                              echo 2
                              echo $OS_VERSION
                              echo $SHELL
                              hostname
                              '''
                             """
                     }

                }
           
             }
          }
       }
    }

  • 相关阅读:
    Firemonkey 控件设定字型属性及颜色
    ListView 使用 LiveBindings 显示超过 200 条记录
    Firemonkey ListView 获取项目右方「>」(Accessory) 事件
    XE7 Update 1 选 iOS 8.1 SDK 发布 iPhone 3GS 实机测试
    Firemonkey Bitmap 设定像素颜色 Pixel
    Firemonkey 移动平台 Form 显示使用 ShowModal 范例
    XE7 提交 App(iOS 8)提示「does not contain the correct beta entitlement」问题修复
    XE7 Android 中使用 MessageDlg 范例
    导出 XE6 预设 Android Style (*.style) 档案
    修正 Memo 設定為 ReadOnly 後, 無法有複製的功能
  • 原文地址:https://www.cnblogs.com/i-shu/p/15201188.html
Copyright © 2011-2022 走看看