Jenkins: 如何更新当前构建名称和描述
How to update the current build name and description.
Jenkins is a famous and mostly used CI tool and we are also using it for build and release and other automated jobs. We also have a deployment job that deploys the selected artifact version to selected server groups (similar to autoscaling groups in AWS) in the selected environment. The job is working as expected. By default, Jenkins set the build name as the build number (see the red color box in the below snapshot). what if somebody wants to know to which environment and server group 3rd or 4th build jobs deployed? In that case, we have to open the job details and needs to check. Jenkins 是一个著名的、最常用的 CI 工具,我们也用它来构建和发布以及其他自动化工作。我们还有一个部署作业,可将所选构件版本部署到所选环境中的选定服务器组(类似于 AWS 中的自动扩展组)。作业按预期工作。默认情况下,Jenkins 将构建名称设置为内部版本号(请参阅下面快照中的红色框)。如果有人想知道部署了哪个环境和服务器组的第 3 个或第 4 个生成作业,该怎么办?在这种情况下,我们必须打开作业详细信息并需要检查。
But for the 6th,7th, and 8th builds, by seeing the build details themselves without opening, we can get all the important details. This can be achieved by updating the currentBuild.displayName and currentBuild.description variables.
但是对于第 6、7 和 8 个构建,通过不打开即可查看构建细节本身,我们可以获得所有重要细节。这可以通过更新currentBuild.displayName
和currentBuild.description
变量来实现。
Sample template 示例模板:
pipeline {
agent any
parameters {
choice choices: ['develop', 'test', 'state', 'prod'], description: 'Select the target environment.', name: 'ENVIRONMENT_NAME'
choice choices: ['ServerGRoupA', 'ServerGRoupB', 'ServerGRoupC'], description: 'Select the target server group name.', name: 'SERVER_GROUP_NAME'
string defaultValue: '1.0.0',description: 'Enter artifact version to be deployed', name: 'ARTIFACT_VAERSION'
}
stages {
stage('Initilization') {
steps {
echo 'Initilizating'
script{
currentBuild.displayName = "#${BUILD_NUMBER} - ${params.ENVIRONMENT_NAME} - ${params.SERVER_GROUP_NAME} -${params.ARTIFACT_VAERSION}"
currentBuild.description = "Deploying ${params.ARTIFACT_VAERSION} to ${params.SERVER_GROUP_NAME} in ${params.ENVIRONMENT_NAME}"
}
}
}
stage('Download Atrifacts') {
steps {
echo "Downloading ${params.ARTIFACT_VAERSION} Atrifacts"
}
}
stage('Deploy Atrifacts') {
steps {
echo "Deploying ${params.ARTIFACT_VAERSION} Atrifacts to ${params.SERVER_GROUP_NAME} in ${params.ENVIRONMENT_NAME}"
}
}
}
}
I Hope, You liked this article. More articles related to DevOps tools, Linux and AWS on the way so please follow me for getting notifications. Bye for now ?.
我希望,你喜欢这篇文章。更多与DevOps工具,Linux和AWS相关的文章即将发布,因此请关注我以获取通知。暂时?再见.
相关文章
- 记一次synchronized锁字符串引发的坑兼再谈Java字符串
- Java对List分割及使用Spring多线程调用
- Java接口幂等性
- Java 相同类型强制转换异常
- 和付费网盘说再见,跟着本文自己起个网盘(Java 开源项目)
- 有了这个开源 Java 项目,开发出炫酷的小游戏好像不难?
- 超级好用的 Java 数据可视化库:Tablesaw
- 采用开源Zabbix+500块硬件平替5万块动环检测系统,实现UPS、温湿度、烟雾等数据采集、存储、告警、大屏展示
- 驱动开发:WinDBG 常用调试命令总结
- 中小企业快速合规,快速部署开源堡垒机TELEPORT
- 驱动开发:监控进程与线程对象操作
- 客快物流大数据项目(九十六):ClickHouse的VersionedCollapsingMergeTree深入了解
- 软件测试|selenium屏幕操作事件TouchActions
- FPS游戏:视场角矩阵的特点
- Path Finder for Mac(强大的文件管理工具)v2149中文激活版
- 零售行业R公司对接亚马逊Amazon Device EDI项目案例
- FPS 游戏:快速寻找基址的方法
- 7min到40s:SpringBoot启动优化实践
- 客快物流大数据项目(九十九):Clickhouse中update/delete的使用
- 手把手教你使用CNN进行交通标志识别(已开源)