在Jenkins管道中使用Azure CLI [英] Using Azure CLI in Jenkins pipeline
问题描述
我正在尝试通过本教程在Azure中使用Jenkins管道: https://docs.microsoft.com/zh-cn/azure/jenkins/execute-cli-jenkins-pipeline ,但我在本地主机上具有Jenkins(运行Win7).
I'm trying to use the Jenkins pipeline with Azure using this tutorial: https://docs.microsoft.com/en-us/azure/jenkins/execute-cli-jenkins-pipeline with the exception that I have Jenkins on localhost (running Win7).
该构建按预期工作,但是在Jenkinsfile中应运行"az login ..."脚本的行上部署失败,并出现找不到命令"错误.
The build works as expected, but deployment fails on the line in Jenkinsfile where the 'az login...' script should run, with a 'command not found' error.
withCredentials([azureServicePrincipal('...')]) {
sh '''
'az login ..'
我可以在Jenkins之外的命令行中使用'az'命令.
I am able to use the 'az' commands in the command line outside of Jenkins.
我错过了什么吗?任何帮助将不胜感激.
Am I missing something? Any help would be appreciated.
推荐答案
您需要将Azure服务主体添加到Jenkins凭据.请参考您提供的="=" nofollow noreferrer>链接.
You need to add Azure service principal to Jenkins credential. Please refer to the link you provided.
如果没有服务主体,则可以使用Azure CLI 2.0创建新的主体.请参考此
If you don't have a service principal, you could use Azure CLI 2.0 to create a new. Please refer to this link:Create an Azure service principal with Azure CLI 2.0.
withCredentials([azureServicePrincipal('<mySrvPrincipal>')])
<mySrcvPrincipal>
是您设置的凭据ID.
<mySrcvPrincipal>
is credential id you set.
注意:
将Azure服务主体添加到Jenkins凭据时,请单击验证服务主体",请确保您还看到已成功验证Microsoft Azure服务主体.
When you add Azure service principal to Jenkins credential, click Verify Service Principal, please ensure you also see Successfully verified the Microsoft Azure Service Principal.
这篇关于在Jenkins管道中使用Azure CLI的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!