最近,一个小需求,动态建立slave节点来执行自动化用例,原有jenkins 老方式不满足需求,就用到jenkins2的pipeline来实现,但在实现过程中,2个小坑记录下

1、jenkins不能读取file参数中的文件

在任务有file参数时,如下:

然后在pipeline只引用env.env_conf时,发现找不到上传的文件.....<_>

查看后,原来还是一个bug,见jenkins官网说明,

代替方案:

使用multi-line string parameter参数,读取后,再写入到文件

writeFile file: 'demo.ini', text: env.config

2、post带node,带脚本

post属于构建后的操作,官网只是这样显示的

Jenkinsfile (Declarative Pipeline)
pipeline {
agent any
stages {
stage('Test') {
steps {
sh 'echo "Fail!"; exit 1'
}
}
}
post {
always {
echo 'This will always run'
}
success {
echo 'This will run only if successful'
}
failure {
echo 'This will run only if failed'
}
unstable {
echo 'This will run only if the run was marked as unstable'
}
changed {
echo 'This will run only if the state of the Pipeline has changed'
echo 'For example, if the Pipeline was previously failing but is now successful'
}
}
}

NND,这是什么,谁的post会这么简单??

我要在指定节点运行脚本,发邮件。

没办法,又是查阅资料后,原来post可以这么写:

例一:

post {
success {
script {
currentBuild.result = 'SUCCESS'
}
step([$class: 'StashNotifier'])
}
}
例二:带节点生成html,junit

post {
always {
node("xxxxx"){
publishHTML (target: [
allowMissing: false,
alwaysLinkToLastBuild: false,
keepAll: true,
reportDir: "${env.Version}/AliApiCrul/.",
reportFiles: 'index.html',
reportName: "HTML Report"
])
junit "${env.Version}/AliApiCrul/*.xml"
}

jenkins之 pipeline 小尝试的更多相关文章

  1. 远程触发Jenkins的Pipeline任务的并发问题处理

    前文概述 本文是<远程触发Jenkins的pipeline任务>的续篇,上一篇文章实战了如何通过Http请求远程触发指定的Jenkins任务,并且将参数传递给Jenkins任务去使用,文末 ...

  2. [转]利用Jenkins的Pipeline实现集群自动化部署SpringBoot项目

    环境准备 Git: 安装部署使用略. Jenkins: 2.46.2版本安装部署略(修改jenkins执行用户为root,省得配置权限) JDK: 安装部署略. Maven: 安装部署略. 服务器免密 ...

  3. Jenkins流水线(pipeline)实战之:从部署到体验

    关于Jenkins流水线(pipeline) Jenkins 流水线 (pipeline) 是一套插件,让Jenkins可以实现持续交付管道的落地和实施. 关于blueocean Blue Ocean ...

  4. 远程触发Jenkins的Pipeline任务

    场景 虽然能配置提交代码时触发Jenkins任务,但有时并不需要每次提交代码都触发,而是仅在有需要时才执行. 除了在Jenkins页面上手动执行任务,还可以向Jenkins网站发起HTTP请求,触发指 ...

  5. Jenkins的Pipeline脚本在美团餐饮SaaS中的实践

    一.背景 在日常开发中,我们经常会有发布需求,而且还会遇到各种环境,比如:线上环境(Online),模拟环境(Staging),开发环境(Dev)等.最简单的就是手动构建.上传服务器,但这种方式太过于 ...

  6. Jenkins的Pipeline脚本在美团餐饮SaaS中的实践(转)

    一.背景 在日常开发中,我们经常会有发布需求,而且还会遇到各种环境,比如:线上环境(Online),模拟环境(Staging),开发环境(Dev)等.最简单的就是手动构建.上传服务器,但这种方式太过于 ...

  7. jenkins~管道Pipeline的使用,再见jenkinsUI

    Pipeline在Jenkins里的作用 最近一直在使用jenkins进行自动化部署的工作,开始觉得很爽,省去了很多重复的工作,它帮助我自动拉服务器的代码,自动还原包包,自动编译项目,自动发布项目,自 ...

  8. Jenkins和pipeline

    Jenkins https://jenkins.io/index.html The leading open source automation server, Jenkins provides hu ...

  9. jenkins的pipeline的使用

    1.安装Pipeline Maven Integration Plugin 2.新建任务 3.编写pipeline代码 node { stage('get clone') { checkout([$c ...

随机推荐

  1. 全景分割pipeline搭建

    全景分割pipeline搭建 整体方法使用语义分割和实例分割结果,融合标签得到全景分割结果: 数据集使用:panoptic_annotations_trainval2017和cityscapes; p ...

  2. 数据库 简介 升级 SQLite 总结 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  3. PL/SQL学习笔记之异常

    一:异常 程序执行过程中出现错误情况被称为异常,主要有两种类型的异常: 系统定义的异常 用户定义的异常 二:系统定义的异常 Exception Oracle Error SQLCODE 描述 ACCE ...

  4. 启动Jupyter Notebook

    按照图所示,在命令下输入ipython notebook 即可启动Jupyter. 启动后的效果:

  5. 对象拷贝:jQuery extend

    今天操作一个Array数组对象,本来想着先取出该数组某一行数据,然后把该数据当作另一份数据进行操作. 结果发现,对该数据操作的同时,也对Array数组进行了修改,因为这个数据指向了array数组对象. ...

  6. Linux下计算进程的CPU占用和内存占用的编程方法[转]

    from:https://www.cnblogs.com/cxjchen/archive/2013/03/30/2990548.html Linux下没有直接可以调用系统函数知道CPU占用和内存占用. ...

  7. [svc]linux的ip命令操作接口和路由表

    参考: https://www.tecmint.com/ip-command-examples/ 学会linux的配置ip,配置网关,添加路由等命令 man ip man ip address man ...

  8. lua -- 生成协议

    这是爬塔的协议 <?xml version="1.0" encoding="utf-8" ?> <coder name="Tower ...

  9. Goldengate OGG常见问题与错误列表

     Goldengate OGG常见问题与错误列表  以下列出了OGG一些常见的问题与错误及其解答:   Note: 966211.1 How To Resync A Single Table With ...

  10. 怎样找回被删除的EXCEL

    我使用的是腾讯管家进行文件恢复,步骤如下: (1)打开电脑管家,选择工具箱. (2)找到文件找回,点击. (3)选择恢复被删除的文件. (4)选择我们删除的文件. (5)文件还原后路径,点击“确认还原 ...