使用Jenkins可视化您的部署

Have you ever asked yourself or your colleague “Which version is currently deployed on the development environment?” or “Hey John, did you deploy that fix to production yesterday?” or “Bill, our client experienced a bug two days ago. Do you remember which version was deployed at that time?”.

您是否曾经问过自己或同事“开发环境中当前部署了哪个版本?” 或“嘿约翰,您昨天将修补程序部署到生产了吗?” 或“比尔,我们的客户两天前遇到了一个错误。 您还记得当时部署的版本吗?”。

If questions like this regularly pop up, and you use Jenkins for their CI/CD process, this plugin is definitely for you!

如果经常出现诸如此类的问题,并且您使用Jenkins进行其CI / CD处理,那么此插件绝对适合您!

In the world of Agile development, we have to update our software applications very often. Each version should be deployed to numerous environments. Eventually, it becomes a mess when we talk about which version is deployed to which environment. It would be nice to have an overall deployment status in one place, right?

在敏捷开发的世界中,我们必须经常更新我们的软件应用程序。 每个版本都应部署到众多环境中。 最终,当我们谈论将哪个版本部署到哪个环境时,情况变得一团糟。 将整体部署状态放在一个地方会很好,对吗?

At Namecheap, we use Jenkins for CI\CD processes. So we decided to make sure we could always check every deployment status by writing a Jenkins plugin called Deploy Dashboard.

在Namecheap,我们将Jenkins用于CI \ CD进程。 因此,我们决定通过编写一个名为Deploy Dashboard的Jenkins插件来确保始终检查每个部署状态。

In this article, I will show you the capabilities of the plugin and how to use it.

在本文中,我将向您展示该插件的功能以及如何使用它。

使用Deploy Dashboard进行可视化 (Visualizing with Deploy Dashboard)

First of all, we wanted to know what code release versions have been deployed to what test and production environments (or devices). To cover this goal we made a custom view that is used as a dashboard.

首先,我们想知道哪些代码发布版本已部署到哪些测试和生产环境(或设备)。 为了实现此目标,我们制作了一个自定义视图,用作仪表板。

Image for post
Example of the Deployment View
部署视图示例

Moreover, it is possible to look at release history by clicking on a specific environment.

此外,可以通过单击特定环境查看发布历史。

Image for post
History of the deployments to selected environment
到所选环境的部署历史

入门:将新版本添加到仪表板 (Getting Started: Add a New Release to Dashboard)

Let’s assume that you already have a Jenkins job that builds and deploys your application. The only thing you have to do is to call the addDeployToDashboard method with the environment name and app version parameters.

假设您已经有一个Jenkins作业可以构建和部署您的应用程序。 您唯一要做的就是使用环境名称和应用程序版本参数调用addDeployToDashboard方法。

properties([parameters([
string(name: 'version', description: 'App version to deploy'),
choice(
name: 'env',
choices: ['dev', 'prod'],
description: 'Environment where the app should be deployed'
)
])])node {
//...
stage("Deploy") {
// Deploy app version ${params.version} to ${params.env} env

//add release information to the dashboard
addDeployToDashboard(
env: params.env,
buildNumber: params.version
)
}
}

创建仪表板 (Create a Dashboard)

On the Jenkins main page or folder, click the + tab to start the new view wizard (If you don’t see a +, it’s likely you do not have permission to create a new view).

在Jenkins主页或文件夹上,单击+选项卡以启动新视图向导(如果看不到+,则可能是您无权创建新视图)。

Image for post

On the “create new view” page, give your view a name and select the Deployment View type and click ok.

在“创建新视图”页面上,为视图命名,然后选择“部署视图”类型,然后单击“确定”。

Image for post

A regular expression can be used to specify the jobs to include in the view. (e.g.: “.*” will select all the jobs in the folder).

正则表达式可用于指定要包含在视图中的作业。 (例如:“ .* ”将选择文件夹中的所有作业)。

Image for post
Configuration of the Deployment View
部署视图的配置

将部署按钮添加到您的版本 (Add Deployment Buttons to Your Build)

There are cases when you want to keep your CI pipeline separately from CD one. In this case, the Deploy Dashboard Plugin allows you to add additional buttons to the build sidebar. You should just call a buildAddUrl method with a title and URL address.

在某些情况下,您希望将CI管道与CD之一分开保存。 在这种情况下,Deploy Dashboard Plugin允许您向构建侧边栏添加其他按钮。 您应该只使用标题和URL地址调用buildAddUrl方法。

node {
stage("Build") {
String builtVersion = "v2.7.5"
// Build app with ${builtVersion} version //Add buttons to the left sidebar
buildAddUrl(title: 'Deploy to DEV', url: "/job/app-deploy/parambuild/?env=dev&version=${builtVersion}") buildAddUrl(title: 'Deploy to PROD', url: "/job/app-deploy/parambuild/?env=prod&version=${builtVersion}")
}
}
Image for post
Example of the Deployment Buttons on the run details page
运行详细信息页面上的“部署”按钮示例

This feature can be extremely useful for the QA team. They will be able to deploy any existing version to their environment just in a few clicks.

此功能对于质量检查团队非常有用。 只需单击几下,他们就可以将任何现有版本部署到其环境中。

I hope it helps to improve your experience with Jenkins! You are welcome to contribute to the project in GitHub.

我希望它有助于改善您对詹金斯的体验! 欢迎您为GitHub中的项目做出贡献。

翻译自: https://medium.com/namecheap-engineering/visualize-your-deployments-with-jenkins-3d70be6c26b8

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值