jenkins实现持续集成

  • 搭建jenkins环境,安装插件
  • 建立pipeline公用类库,文件夹vars,默认的
  • 添加.groovy文件,可以由以下几个类库组成
    • dockerImageBuild 负责构建项目镜像
    • dockerImageDeploy 负责将镜像推到仓库
    • dockerServiceStart 负责启动docker服务
    • gitCheckout 负责迁出项目源码
    • servicePipeline 程序入口
  • 根据项目添加对应的.jenkinsfile文件
  • jenkins里建立文件夹,选择公用类库的仓库,起个名字
  • 在文件夹里建立新的Job,然后选择对象的jenkinsfile文件
  • 项目构建完成

相关源代码分享

  1. gitCheckout源代码
def call(body) {
def config = [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config
body() echo 'Checking out code from "' + config.repoUrl + '" with credentialsId "' + \
config.credentialsId + '" ...' checkout([$class: 'GitSCM', branches: [[name: config.branches]],
doGenerateSubmoduleConfigurations: false,
extensions: [],
submoduleCfg: [],
userRemoteConfigs: [[credentialsId: config.credentialsId, url: config.repoUrl]]])
}
  1. servicePipeline.groovy源码
def call(body) {
def config = [:]
body.resolveStrategy = Closure.DELEGATE_FIRST
body.delegate = config
body() pipeline {
agent { label 'build-server' } stages {
stage('Initialization') {
steps {
script {
echo "项目初始化"
}
}
}
stage('CI') {
steps{
script{
gitCheckout{
repoUrl = config.repoUrl
credentialsId = config.credentialsId
branches = config.branches
commit = config.commit
}
}
}
}
stage('Service') {
echo "启动dockder服务"
}
}
}
}
  1. lind.jenkinsfile项目部署源码
@Library("lind-library") _

servicePipeline ( {
repoUrl = "git@github.com:bfyxzls/LindDotNetCore.git"
credentialsId = "012f0d4e-47e2-48ce-8b9e-cd399e9b3d61"
branches = "dev"
})

事实上,上面的构建只是一个基础版本,当你的构建有多种语言组成时,你需要为他们分别写一个入口,如dotnet,nodejs,java,php,它们有自己的入口,然后再servicePipeline里去分别处理,前开发人员输入语言类型,然后统一进行处理。

Jenkins-pipeline的实现步骤的更多相关文章

  1. 在容器中运行 Jenkins pipeline 任务

    持续集成中的 pipeline 技术和 docker 都是当前正在发展的主流方向,当然把它们结合起来在 CI/CD 过程中发挥出更强大的威力也是大家共同的目标.本文将介绍如何在 Jenkins pip ...

  2. 基于Jenkins Pipeline的ASP.NET Core持续集成实践

    最近在公司实践持续集成,使用到了Jenkins的Pipeline来提高团队基于ASP.NET Core API服务的集成与部署效率,因此这里总结一下. 一.关于持续集成与Jenkins Pipelin ...

  3. Jenkins pipeline:pipeline 使用之语法详解

    一.引言 Jenkins 2.0的到来,pipline进入了视野,jenkins2.0的核心特性. 也是最适合持续交付的feature. 简单的来说,就是把Jenkins1.0版本中,Project中 ...

  4. Jenkins pipeline:pipeline 语法详解

    jenkins  pipeline 总体介绍 pipeline 是一套运行于jenkins上的工作流框架,将原本独立运行于单个或者多个节点的任务连接起来,实现单个任务难以完成的复杂流程编排与可视化. ...

  5. Jenkins 配置邮件通知步骤

    Jenkins 配置邮件通知前言 可以在Jenkins 中配置邮件通知,比如在构建失败时发送邮件通知项目组来及时修复问题. Jenkins 邮件通知功能的插件主要包括: Mailer Plugin ( ...

  6. Jenkins pipeline shared library

    Jenkinsfile https://jenkins.io/doc/book/pipeline/jenkinsfile/ Jenkins Pipeline is a suite of plugins ...

  7. Jenkins pipeline概念理解

      1.Jenkins Pipeline总体介绍 Pipeline,简而言之,就是一台运行于Jenkins上的工作流框架,将原本独立运行于单个或者多个节点的任务连接起来,实现单个任务难以完成的复杂流程 ...

  8. Jenkins pipeline 语法详解

    原文地址http://www.cnblogs.com/fengjian2016/p/8227532.html pipeline 是一套运行于jenkins上的工作流框架,将原本独立运行于单个或者多个节 ...

  9. 转~Jenkins pipeline:pipeline 使用之语法详解

    一.引言 Jenkins 2.0的到来,pipline进入了视野,jenkins2.0的核心特性. 也是最适合持续交付的feature. 简单的来说,就是把Jenkins1.0版本中,Project中 ...

  10. [转] Jenkins Pipeline插件十大最佳实践

    [From] http://blog.didispace.com/jenkins-pipeline-top-10-action/ Jenkins Pipeline 插件对于 Jenkins 用户来说可 ...

随机推荐

  1. python(1)在windows8.1下搭建python27和python36环境

    去Python官网下载需要的Python版本 https://www.python.org/ 我下载的是下面这两个版本: Python 2.7.13 Python 3.6.1 安装Python27时, ...

  2. mac中导出CSV格式在excel中乱码

    1 - 首先需要查看文档的编码格式: 安装enca:  brew install enca 使用命令 enca  file路径即可查到文件的编码格式 Universal transformation ...

  3. Linux CentOS 5.5 服务器安装图文教程

    下面开始: 系统版本:CentOS 5.5 将镜像刻成光盘,设置BIOS将CDROM设置为第一启动 启动画面: 通过提示,按ENTER进入图形安装模式(E文不好的,赶紧补习去哈~~~) 我们按ENTE ...

  4. Leetcode--1. Two Sum(easy)

    Given an array of integers, return indices of the two numbers such that they add up to a specific ta ...

  5. limit

    在我们使用查询语句的时候,经常要返回前几条或者中间某几行数据,这个时候怎么办呢?不用担心,mysql已经为我们提供了这样一个功能. SELECT * FROM table  LIMIT [offset ...

  6. noah

    1.url:controller/method 2.在index.php中设置display_errors:1 能看到错误提示

  7. MySQL--eq_range_index_dive_limit参数学习

    官方文档如下描述:This variable indicates the number of equality ranges in an equality comparison condition w ...

  8. 使用EF6连接mariaDB出现中文查找不到数据的问题

    1.问题描述 这两天使用ef6.0查询mariaDB出现了数据查询不到的情况 2.问题分析 后来发现除了这段数据查询不到,其他都能查询,于是逐步对比代码,发现其他数据都是英文的,而这句是中文的于是把条 ...

  9. Codeforces Round #469 (Div. 2)C. Zebras(思维+模拟)

    C. Zebras time limit per test memory limit per test 512 megabytes input standard input output standa ...

  10. 获取请求地址的IP地址

    public static String getIpAddr(HttpServletRequest request) throws Exception { String ip = request.ge ...