前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Jenkins: 如何更新当前构建名称和描述

Jenkins: 如何更新当前构建名称和描述

作者头像
DevOps云学堂
发布2022-12-29 17:14:58
1.1K0
发布2022-12-29 17:14:58
举报
文章被收录于专栏:DevOps持续集成DevOps持续集成

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.displayNamecurrentBuild.description变量来实现。 Sample template 示例模板:

代码语言:javascript
复制
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相关的文章即将发布,因此请关注我以获取通知。暂时😀再见.


本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2022-11-29,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 DevOps云学堂 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
CODING DevOps
CODING DevOps 一站式研发管理平台,包括代码托管、项目管理、测试管理、持续集成、制品库等多款产品和服务,涵盖软件开发从构想到交付的一切所需,使研发团队在云端高效协同,实践敏捷开发与 DevOps,提升软件交付质量与速度。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档