推荐使用Jenkinsfile代替将groovy脚本直接写在jenkins job里。

文章来自:http://www.ciandcd.com
文中的代码来自可以从github下载: https://github.com/ciandcd

推荐将pipeline的groovy脚本放到Jenkinsfile且保存到跟源代码相同的目录下。通过这种方法实现了groovy脚本与源代码都被版本控制,更好地支持构建的可重现性。

本文用到的测试repo:https://github.com/ciandcd/simple-maven-project-with-tests.git

测试repo下的Jenkinsfile:https://github.com/ciandcd/simple-maven-project-with-tests/blob/master/Jenkinsfile

1. Jenkinsfile的内容如下:

node (){
stage 'Build and Test'
env.PATH = "${tool 'M3'}/bin:${env.PATH}"
//checkout scm
git url:"https://github.com/ciandcd/simple-maven-project-with-tests.git"
sh 'mvn clean package'
}

2. 配置jenkins pipleline job来使用Jenkinsfile

3. 运行pipleline job将会看到如下view

jenkins2 Jenkinsfile的更多相关文章

  1. jenkins2 Jenkinsfile和load

    更复杂的pipeline实例,使用了Jenkinsfile和load. 文章来自:http://www.ciandcd.com 文中的代码来自可以从github下载: https://github.c ...

  2. Jenkins pipeline 入门到精通系列文章

    Jenkins2 入门到精通系列文章. Jenkins2 下载与启动jenkins2 插件安装jenkins2 hellopipelinejenkins2 pipeline介绍jenkins2 jav ...

  3. Jenkins2.0中的pipeline

    jenkins的实现是标准的master/slave模式,用户与master交互,master将job分布到slave上运行. jenkins的基本概念: 1. master, 也就是jenkins的 ...

  4. jenkins2 pipeline 语法快速参考

    jenkins2 pipeline中常用的语法快速参考. 文章来自:http://www.ciandcd.com文中的代码来自可以从github下载: https://github.com/ciand ...

  5. jenkins2 pipeline插件的10个最佳实践

    jenkins pipeline的10个最佳实践. 文章来自:http://www.ciandcd.com文中的代码来自可以从github下载: https://github.com/ciandcd ...

  6. jenkins2 multibranch

    通过multibranch类型的pipeline job使得对于多个branch的支持更加简单.只需要创建一个multibranch job,jenkins将自动地为所有的branch创建job. 文 ...

  7. jenkins2 pipeline高级

    jenkins2 pipeline里groovy的高级用法.翻译自:https://github.com/jenkinsci/pipeline-plugin/blob/master/TUTORIAL. ...

  8. jenkins2 pipeline介绍

    文章来自:http://www.ciandcd.com 文中的代码来自可以从github下载: https://github.com/ciandcd   什么是jenkins2的pipeline?   ...

  9. jenkins2 hello pipeline

    文章来自:http://www.ciandcd.com 文中的代码来自可以从github下载: https://github.com/ciandcd   根据前面的2篇文章,我们已经安装和配置好了je ...

随机推荐

  1. oracle rownum paging issues

    rownum是oracle预处理字段,默认标序是1,只有记录集已经满足条件后才会进行后续编号.由于第一条记录rownum默认是1,而你的条件是rownum>=6 对第一条记录比较它的rownum ...

  2. Linux内核分析第五周学习总结:扒开系统调用的三层皮(下)

    韩玉琪 + 原创作品转载请注明出处 + <Linux内核分析>MOOC课程http://mooc.study.163.com/course/USTC-1000029000 一.给MenuO ...

  3. node.js 基础学习笔记2

    Module和Package是Node.js最重要的支柱. Node.j 提供require函数来调用其他模块,而且模块都是基于文件.模块和包区别是透明的,因此常常不作区分. 1.模块和文件一一对应. ...

  4. nil、Nil、NULL和NSNull的区别和联系

    一.nil 我们给对象赋值时一般会使用object = nil,表示我想把这个对象释放掉: 或者对象由于某种原因,经过多次release,于是对象引用计数器为0了,系统将这块内存释放掉,这个时候这个对 ...

  5. 2016---ios面试题

    1.对数组中的元素去重复 例如:   1 2 3   NSArray *array = @[@"12-11", @"12-11", @"12-11&q ...

  6. 测试C++代码与WebBrowser HTML的互动

    testWebBrowserDlg.h // testWebBrowserDlg.h : 头文件 // #pragma once #include "explorer1.h" #i ...

  7. 设置mysql 数据集为utf-8

    To set the default to UTF-8, you want to add the following to my.cnf [client] default-character-set= ...

  8. Java关键字:transient,strictfp和volatile简介

    关键字:transient 使用对象:字段 介绍:transient说明一个属性是临时的,不会被序列化. 当对象进行序列化(Serializable)过程时候,有一些属性的状态是瞬时的,这样的对象是无 ...

  9. Codeforces 723C. Polycarp at the Radio 模拟

    C. Polycarp at the Radio time limit per test: 2 seconds memory limit per test: 256 megabytes input: ...

  10. mORMot使用基础

    mORMot 名称来自Marmot,对,土拨鼠,俗称旱獭,是一种生活在高寒山区的动物.多数都在白天活动,喜群居,善掘土,所挖地道深达数米,内有铺草的居室,非常舒适.通常洞穴都会有两个以上的入口,以策安 ...