当前位置:网站首页>Jenkins - Groovy Postbuild 插件丰富 Build History 信息
Jenkins - Groovy Postbuild 插件丰富 Build History 信息
2022-06-28 00:15:00 【wumingxiaoyao】
引言
对于共用的 Jenkins Job,会被多个 Jenkins Pipleline Job 调用,例如每次执行完测试用例,发送 Email Report 告知测试结果,便可以单独建一个公用的 Report jenkins job,方便多个项目调用。通常 Jenkins job 执行完,只有 Build Number 和完成时间,要想知道具体细节还得点开每个 Build,不够直观。Groovy Postbuild 插件就可以解决这个问题,可以让 Build History 的内容更加丰富。
内容提要
- Groovy Postbuild 插件介绍
- 安装 Groovy Postbuild 插件
- 应用 Groovy Postbuild 插件
Groovy Postbuild 插件介绍
Groovy Postbuild 官网 有介绍到,该插件在 Jenkins JVM 执行 Groovy 脚本。通常基于 build 的运行结果,check 一些条件和变化。例如,可以在 build history 中 build 旁边添加图标 badges 或是显示有关 build 的描述。
自 Groovy Postbuild 2.0 起,开始引入 Script Security Plugin,为了控制 Groovy 脚本使用的安全性,防止不当的使用造成的危害。
因此 Groovy Postbuild 有 2 类方法:
- White 白名单方法,可用 Groovy sandbox 运行
- Non White 非白名单方法,需要 Admin 批准以后才能用 Manage Jenkins > In-process Script Approval。
受权限制约,本文应用部分使用的是 White 白名单方法 中的简单方法。
安装 Groovy Postbuild 插件
在应用 Groovy Postbuild 插件前,先确保 Jenkins 上已经安装该插件
Manage Jenkins -> Plugin Manage
安装完成后,发现多出一个 Groovy Postbuild 选项
Job Configure -> Post-build Actions -> Add post-build action
应用 Groovy Postbuild 插件
先看一下,没有应用 Groovy Postbuild plugin 时,Build History 的信息就只有 build number 和 执行时间。
应用后的效果可以是这样的:加了一些高亮文本和图标,这里只是举个例子,你也可以基于自己的需求定制。这样就能区分是那个 Project Name 执行的 Job 了,是不是一目了然。
下面来看看上面的效果是怎么实现,
添加一个参数 Project_Name,用来选择 Porject Name,后面 Groovy postbuild 需要访问这个参数。
Post-build Actions 部分添加 Groovy Postbuild plugin${manager.getEnvVariable('Project_Name')} 可以访问到 Project_Name 变量
Groovy script:
manager.addShortText("${manager.getEnvVariable('Project_Name')}")
manager.addBadge("success.gif", "success")
manager.addWarningBadge("build Failure.")
manager.addBadge("error.gif", "failed")
边栏推荐
猜你喜欢

数据库的新选择 Amazon Aurora

Appium自动化测试基础 — ADB常用命令(一)

【牛客討論區】第四章:Redis

Lmsoc: a socially sensitive pre training method

Ten thousand words long article understanding business intelligence (BI) | recommended collection

Implementation of timed tasks in laravel framework

评价——秩和比综合评价

Adobe Premiere基础-常用的视频特效(边角定位,马赛克,模糊,锐化,手写工具,效果控件层级顺序)(十六)

什麼是數字化?什麼是數字化轉型?為什麼企業選擇數字化轉型?

Evaluation - rank sum ratio comprehensive evaluation
随机推荐
Cesium 点击获取经纬度(二维坐标)
Is it safe to open an online futures account?
Interviewer asked: Inheritance of JS
评价——灰色关联分析
How fiddle uses agents
Solve storage problems? WMS warehouse management system solution
[Yocto RM]3 - Yocto Project Releases and the Stable Release Process
Machine learning notes - time series as features
[Yocto RM]9 - QA Error and Warning Messages
Cesium Color 颜色(赋值)随机颜色
什么是数字化?什么是数字化转型?为什么企业选择数字化转型?
Original | 2025 to achieve the "five ones" goal! The four products of Jiefang power are officially released
Data analysts too hot? Monthly income 3W? Tell you the true situation of this industry with data
Maimai hot post: Why are big factories keen on making wheels?
pytorch_lightning.utilities.exceptions.MisconfigurationException: You requested GPUs: [1] But...
Xctf attack and defense world misc wage earner advanced zone
嵌入式必学,硬件资源接口详解——基于ARM AM335X开发板 (上)
TI AM3352/54/59 工业核心板硬件说明书
PV operation primitive
I/O限制进程与CPU限制进程