zoukankan      html  css  js  c++  java
  • Jenkins和pipeline

    Jenkins

    https://jenkins.io/index.html

    The leading open source automation server, Jenkins provides hundreds of plugins to support building, deploying and automating any project.

    http://www.cnblogs.com/itech/archive/2011/11/23/2260009.html

    Jenkins的突出特点:

    开源免费;

    跨平台,支持所有的平台;

    master/slave支持分布式的build;

    web形式的可视化的管理页面;

    安装配置超级简单;

    tips及时快速的帮助;

    已有的200多个插件;

    Pipeline

    https://jenkins.io/doc/book/pipeline/

    Jenkins Pipeline is a suite of plugins which supports implementing and integrating continuous delivery pipelines into Jenkins. Pipeline provides an extensible set of tools for modeling simple-to-complex delivery pipelines "as code" via the Pipeline DSL. [1]

    Typically, this "Pipeline as Code" would be written to a Jenkinsfile and checked into a project’s source control repository, for example:

    pipeline {
        agent any 
    
        stages {
            stage('Build') { 
                steps { 
                    sh 'make' 
                }
            }
            stage('Test'){
                steps {
                    sh 'make check'
                    junit 'reports/**/*.xml' 
                }
            }
            stage('Deploy') {
                steps {
                    sh 'make publish'
                }
            }
        }
    }

    典型场景: devops 下载 编译 测试 部署

     Parallelism and Distributed Builds with Jenkins

     https://www.cloudbees.com/blog/parallelism-and-distributed-builds-jenkins

       parallel (
         "stream 1" : { ... things ...  },
         "stream 2" : { ... things in parallel ... }
       )

    https://issues.jenkins-ci.org/browse/JENKINS-33185

     for (int i=0; i< 2; ++i) {
      stage "Stage #"+i
      print 'Hello, world $i!'
    }

    stage "Stage Parallel"
    def branches = [:]
    for (int i = 0;  i < numHelloMessages.toInteger();  i++) {
      branches["split $ {i}"] = {
        stage "Stage paralle l - #" + i
        node('remote') {
         echo  'Starting sleep'
         sleep 10
         echo  'Finished sleep'
        }
      }
    }
    parallel branches

    Jenkins file样例库

    https://github.com/jenkinsci/pipeline-examples/blob/master/pipeline-examples/jobs-in-parallel/jobs_in_parallel.groovy

    // in this array we'll place the jobs that we wish to run
    def branches = [:]

    //running the job 4 times concurrently
    //the dummy parameter is for preventing mutation of the parameter before the execution of the closure.
    //we have to assign it outside the closure or it will run the job multiple times with the same parameter "4"
    //and jenkins will unite them into a single run of the job

    for (int i = 0; i < 4; i++) {
      def index = i //if we tried to use i below, it would equal 4 in each job execution.
      branches["branch${i}"] = {
    //Parameters:
    //param1 : an example string parameter for the triggered job.
    //dummy: a parameter used to prevent triggering the job with the same parameters value. this parameter has to accept a different value
    //each time the job is triggered.
        build job: 'test_jobs', parameters: [[$class: 'StringParameterValue', name: 'param1', value:
          'test_param'], [$class: 'StringParameterValue', name:'dummy', value: "${index}"]]
        }
    }
    parallel branches

  • 相关阅读:
    解决org.openqa.selenium.WebDriverException: Unable to connect to host 127.0.0.1 on port 7055 after 45000 ms org.springframework.beans.BeanInstantiation
    jsp学习---css基础知识学习,float,position,padding,div,margin
    jsp学习---mvc模式介绍和el表达式,jstl标签库的使用入门
    java 查询 mongodb 中的objectid
    jsp学习---使用jsp和JavaBean实现超简单网页计算器
    jsp学习--JavaBean定义和在Jsp中使用JavaBean
    jsp学习--如何定位错误和JSP和Servlet的比较
    jsp学习--JSP运行原理,九大隐式对象和JSP常用标签
    jsp学习--基本语法和基础知识
    android开发学习---layout布局、显示单位和如何进行单元测试
  • 原文地址:https://www.cnblogs.com/lightsong/p/6880459.html
Copyright © 2011-2022 走看看