使用Jenkins进行Azure置备 [英] Azure provisioning with Jenkins

查看:295
本文介绍了使用Jenkins进行Azure置备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

作为QA流程的一部分(在Jenkins中),目标是自动化VM的配置和配置以运行QA测试.

As part of QA pipeline(in Jenkins), goal is to automate provisioning and configuration of a VM to run the QA tests.

Jenkins管道可以触发Terraform代码自动执行VM的配置和用于配置VM的可行代码,但是,除非我们执行回滚错误处理之类的问题,否则并不容易使用某些特定于供应商的模板,例如AzureResourceManager模板.

Jenkins pipeline can trigger Terraform code to automate provisioning of VM and ansible code for configuration of a VM, but, issues like rollback, error handling is not easy unless we use some vendor specific template like AzureResourceManager template.

因此,使用Jenkins管道,在Azure云中置备和配置VM的最佳方法应该是什么?我们为詹金斯管道编写管道脚本...

So, with Jenkins pipeline,What should be the best approach to provision and configure a VM in Azure cloud? we write pipeline scripts for jenkins pipeline...

推荐答案

目标是了解自动化VM的配置和配置以运行QA测试的最佳方法,因此我将通过利用简单的jenkins管道脚本其中的Azure CLI命令. 确切地说,我只是将Azure服务主体添加到Jenkins凭据中.然后编写简单的Jenkins管道脚本,方法是使用' withCredentials([azureServicePrincipal('SERVICEPRINCIPALCREDENTIALID')] ',然后使用' sh '部分使Azure CLI命令执行供应和配置VM.有关与此相关的说明,您可以参考

As the goal is to know the best approach to automate provisioning and configuration of a VM to run the QA tests so I would go with simple jenkins pipeline script by leveraging Azure CLI commands in it. To be precise, I would just add an Azure service principal to Jenkins credential. And then write simple Jenkins pipeline script by having 'withCredentials([azureServicePrincipal('SERVICEPRINCIPALCREDENTIALID')])' and then by using 'sh' part to have Azure CLI command to provision and configure VM. For illustration related to this you may refer https://docs.microsoft.com/en-us/azure/jenkins/execute-cli-jenkins-pipeline#add-azure-service-principal-to-jenkins-credential.

关于采用Jenkins管道触发Ansible代码(使用或不使用ARM模板)的方法时的回滚和错误处理等问题,该代码可以自动配置和配置VM以运行QA测试,(您可能已经意识到这一点,但是想让您知道)对于某些类型的任务,您可以编写可利用错误处理功能的自定义模块,并且在少数情况下,您可以利用'failed_when'选项.另外,您可以利用块"功能来定义一组要在救援:"部分中执行的任务.这种阻止"功能尤其应有助于使我们能够使事情恢复原状.

Regarding the issues like rollback and error handling when going with the approach of having Jenkins pipeline that triggers Ansible code (with or without using ARM templates) that can automate provisioning and configuration of a VM to run the QA tests, (you might already be aware of this but wanted to let you know that) for certain types of tasks you may write custom modules that can leverage the error handling functionality and in few scenarios you may leverage 'failed_when' option. Also you may leverage 'blocks' functionality by which you can define a set of tasks to be executed in the rescue: section. This 'blocks' functionality specially should help in enabling us to get the things rolled back.

希望这会有所帮助!! :)

Hope this helps!! :)

这篇关于使用Jenkins进行Azure置备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆