jenkins pipeline使用方式
pipeline 使用
使用groovy的一种DSL语言,流程控制 pipeline脚本同其他脚本语言一样,从上到下顺序执行,它的流程控制取决于Groovy表达式,为jenkins用户提供了更巨大的灵活性和可扩展性,本章内容围绕 devops [持续交付实践] pipeline
1.使用声明式写法
agent : 该agent部分指定整个Pipeline或特定阶段将在jenkins环境中执行的位置,具体取决于该agent部分的放置位置。该部分必须在pipeline块内的顶层定义。但stage级使用是可选的
1):any、none、指定slave
any 在任何可用的agent 上执行Pipeline或stage
none 当在pipeline块的顶层使用none时,将不会为整个Pipeline运行分配全局agent ,每个stage部分将需要包含其自己的agent
label 使用提供的label标签,在Jenkins环境中可用的代理上执行Pipeline或stage。例如:agent { label 'my-defined-label' }
parameters:配置部署之前参数。
1):string、password、choice
def name="test1"
def test2(name1){
println name1
if(name1 == "test3"){
println "the is a test name1 is ${name}"
}else{
println "the not is name1 the is ${name}"
} }
pipeline {
agent any
parameters {
string(name: 'username', defaultValue: 'guozh10', description: 'username ')
password(name: 'password', defaultValue: 'password', description: 'password')
choice(name: 'ENV_TYPE', choices: editionName, description: 'test means test env,….')
}
stages {
stage('Non-parallel Stage') {
steps {
echo 'This stage will be executed first.'
}
}
stage('parakked Stage') {
when {
branch 'master'
}
parallel {
stage('Branch A') {
agent {
label "for-branch-a"
}
steps {
echo "On Branch A"
} }
stage('Branch B') {
agent {
label "for-branch-b"
}
steps {
echo "On Branch B"
}
}
}
}
}
}
脚本式
node ("master"){
stage('Example') {
try {
sh 'exit 1'
}
catch (exc) {
echo 'Something failed, I should sound the klaxons!'
throw
}
}
}
node("slave01") {
stage('Example') {
try {
sh 'exit 1'
}
catch (exc) {
echo 'Something failed, I should sound the klaxons!'
throw
}
}
}
jenkins pipeline使用方式的更多相关文章
- Jenkins pipeline job 根据参数动态获取触发事件的分支
此文需要有Jenkins pipeline job 的简单使用经验 场景 我们日常的测试函数, 一般是不能仅仅在本地跑的,还需要一个公共的跑测试的环境,作为合并新的PR的依据. 如果用Jenkins ...
- Jenkins pipeline:pipeline 使用之语法详解
一.引言 Jenkins 2.0的到来,pipline进入了视野,jenkins2.0的核心特性. 也是最适合持续交付的feature. 简单的来说,就是把Jenkins1.0版本中,Project中 ...
- Jenkins pipeline:pipeline 语法详解
jenkins pipeline 总体介绍 pipeline 是一套运行于jenkins上的工作流框架,将原本独立运行于单个或者多个节点的任务连接起来,实现单个任务难以完成的复杂流程编排与可视化. ...
- [持续交付实践] Jenkins Pipeline 高可用设计方法
前言 这篇写好一段时间了,一直也没发布上来,今天稍微整理下了交下作业,部分内容偷懒引用了一些别人的内容.使用Jenkins做持续集成/持续交付,当业务达到一定规模的时候,Jenkins本身就很容易成为 ...
- Jenkins pipeline shared library
Jenkinsfile https://jenkins.io/doc/book/pipeline/jenkinsfile/ Jenkins Pipeline is a suite of plugins ...
- Jfrog Maven jenkins pipeline 流水线 培训 简单实验
1. 公司购买了一套jfrog artifactory ,然后厂商组织了一次培训 本次简单记录一下 jenkins和jfrog 二进制仓库的简单连接使用 2. 前期环境准备. scp jdk的tar包 ...
- jenkins Pipeline 使用
说明 Jenkins pipeline 是一套插件,支持将连续输送管道实施和整合到Jenkins.Pipeline提供了一组可扩展的工具,用于通过管道DSL为代码创建简单到复杂的传送流水线.他目前支持 ...
- Jenkins pipeline 语法详解
原文地址http://www.cnblogs.com/fengjian2016/p/8227532.html pipeline 是一套运行于jenkins上的工作流框架,将原本独立运行于单个或者多个节 ...
- 转~Jenkins pipeline:pipeline 使用之语法详解
一.引言 Jenkins 2.0的到来,pipline进入了视野,jenkins2.0的核心特性. 也是最适合持续交付的feature. 简单的来说,就是把Jenkins1.0版本中,Project中 ...
随机推荐
- .net Core 学习笔记(增加Nlog日志)
https://github.com/NLog/NLog.Web/wiki/Getting-started-with-ASP.NET-Core-2 (日志下载) https://github.com ...
- Natasha V1.3.6.0 的升级日志
开源库满足于个人,而完善于大众. Natasha 自稳定版发布之后,众多老铁参与增强改进,感谢如下老铁的反馈: 1. 异常搜集 在 wenjq0911 建议下,添加了异常捕获,现 Natasha 的编 ...
- JS 弹窗“是否删除”
var r = confirm("是否确认删除!");if (r == true) {location.href = "/Employees/Delete/" ...
- Filco圣手二代双模蓝牙机械键盘的连接方法
常规方法 确认键盘的电源接通. 同时按下「Ctrl」+「Alt」+「Fn」执行装置切换模式.配对LED灯(蓝)和低电量显示LED灯(红)约同时亮10秒左右. 想移除已登录的装置时,请从「蓝牙装置登录/ ...
- Spring IOC 复习
Inversion of Control 将创建对象的权利交给框架,包括DI(Dependency Injection,依赖注入)和DL(Dependency Lookup,依赖查找),能削减计算机程 ...
- BindRequired and Required
[https://www.cnblogs.com/tdfblog/p/required-and-bindrequired-in-asp-net-core-mvc.html] Required:对值进行 ...
- vue-cli随机生成port源码
const portfinder = require('portfinder'): const port = await portfinder.getPortPromise(): 两行代码 端口搜索范 ...
- 实验吧——NSCTF web200
题目地址:http://ctf5.shiyanbar.com/web/web200.jpg 打开就是个自定义加密函数,只要写出相应的解密算法就行 <?php function encode($s ...
- kali2.0升级
1.登录kali2.0系统 2 2.修改软件源APT-sources.list vim /etc/apt/sources.list 3 可以删除该文件中的所有内容,也可以直接在文前添加新的APT源. ...
- rhel7学习第四天
学习<Linux就该这么学>第二周,学习了最重要的几个文件操作命令