jenkins之 pipeline 小尝试
Jenkins 尝试 Pipeline
2023-09-27 14:26:52 时间
最近,一个小需求,动态建立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与.NET项目
- jenkins环境自动部署
- k8s -安装jenkins
- 一文5000字手把手教你使用jenkins搭建一个中小企业前端项目部署环境
- Jenkins Jfrog Artifactory 以及docker下的pipeline 容器编排实践
- 配置gitlab gerrit jenkins
- 【云计算】jenkins,docker,mesos,marathon,k8s相关资料
- K8S 部署 jenkins (一)
- jenkins中windows节点设置开机自启动slave-agent
- deploy jenkins by kubernetes
- Gitlab+Jenkins学习之路(十三)之发布Java项目到tomcat