zoukankan      html  css  js  c++  java
  • 【Jenkins】新版本的特性:自定义流水线

    #!/usr/bin/env groovy
    
    pipeline {
        agent none
        stages {
            stage('stage-01') {
                agent { label 'master' }
                steps {
                    echo 'stage-01'
                    sh 'ifconfig ens33'
                }
            }        
            stage('stage-02') {
                agent { label '10.91.3.213' }
                steps {
                    echo 'stage-02'
                    sh 'source /etc/profile && source ~/.bash_profile && ifconfig ens33'
                }
            }
            stage('stage-03') {
                agent { label '10.91.3.214' }
                steps {
                    echo 'stage-03'
                    sh 'source /etc/profile && source ~/.bash_profile && ifconfig ens33'
                }
            }
            stage('stage-04') {
                steps {
                    script {
                        // labels for Jenkins node types we will build on
                        def labels = ['master', '10.91.3.213', '10.91.3.214']
                        def builders = [:]
                        for (x in labels) {
                            def label = x // Need to bind the label variable before the closure - can't do 'for (label in labels)'
                            // Create a map to pass in to the 'parallel' step so we can fire all the builds at once
                            builders[label] = {
                                node(label) {
                                    // build steps that should happen on all nodes go here
                                    echo 'stage-04 running on: ' + label
                                    // sh 'source /etc/profile && source ~/.bash_profile && echo "stage-04 running on all nodes"'
                                }
                            }
                        }
                        parallel builders
                    }
                }
            }
        }
    }
  • 相关阅读:
    二进制或者其他进制转为十进制
    十进制转为二进制或者其他进制
    0.1 + 0.2 !== 0.3
    [git]删除远程分支
    [git]一个本地仓库,多个远程仓库
    [git]用户名,邮箱
    npm install命令
    常用命令:查看端口
    std::lock_guard 与 std::unique_lock
    std::mutex
  • 原文地址:https://www.cnblogs.com/junneyang/p/9488214.html
Copyright © 2011-2022 走看看