gpt4 book ai didi

azure - 在 Jenkins 管道中使用 Azure CLI

转载 作者:行者123 更新时间:2023-12-03 05:52:31 24 4
gpt4 key购买 nike

我正在尝试使用本教程将 Jenkins 管道与 Azure 结合使用:https://learn.microsoft.com/en-us/azure/jenkins/execute-cli-jenkins-pipeline异常(exception)的是我在本地主机上有 Jenkins(运行 Win7)。

构建按预期工作,但部署在 Jenkinsfile 中应运行“az login...”脚本的线路上失败,并出现“未找到命令”错误。

 withCredentials([azureServicePrincipal('...')]) {
sh '''
'az login ..'

我可以在 Jenkins 之外的命令行中使用“az”命令。

我错过了什么吗?任何帮助将不胜感激。

最佳答案

您需要将 Azure 服务主体添加到 Jenkins 凭据。请引用link您提供的。

如果您没有服务主体,可以使用 Azure CLI 2.0 创建一个新的。请引用这个link:Create an Azure service principal with Azure CLI 2.0 .

withCredentials([azureServicePrincipal('<mySrvPrincipal>')]) 

<mySrcvPrincipal>是您设置的凭证ID。

enter image description here

注意:

将 Azure 服务主体添加到 Jenkins 凭据时,单击“验证服务主体”,请确保您还看到已成功验证 Microsoft Azure 服务主体。

关于azure - 在 Jenkins 管道中使用 Azure CLI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45979852/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com