Jenkins Azure部署错误:az登录错误发布者 [英] Jenkins azure deploy error: az login error issuer

查看:73
本文介绍了Jenkins Azure部署错误:az登录错误发布者的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有自己的groovy脚本,可以在azure应用程序服务上部署一个简单的api(nodejs).

I have my groovy script to deploy a simple api(nodejs) on azure app service.

pipeline {
agent none
environment {
    //app service
    DEV_SERVICE_NAME  = 'xxxxxx'
    ...
    ...

    AZURE_DEV_USER_ID  = 'abcdefghijk'
    AZURE_DEV_PASSWORD = 'xxxxxx'
    AZURE_ACTIVE_DIRECTORY_TENANT_ID = 'xxxxxx'
}
stage('Service Deployment (DEV)'){
   agent { label 'master'}
   steps {
     //Install all packages
     bat "npm i --production"
     ..
     ..
     bat "CALL az login --service-principal --username $env.AZURE_DEV_USER_ID --password $env.AZURE_DEV_PASSWORD --tenant $env.AZURE_ACTIVE_DIRECTORY_TENANT_ID"
     ..
     ..
}

因此,当jenkins生成时,会失败并显示错误

so, when jenkins builds, fails, and print an error

C:\jenkins\workspace\loud_feature-deploy-api-on-azure@2>CALL az login --service-principal --username 
null --password null --tenant null 
usage: az login [-h] [--verbose] [--debug]
            [--output {json,jsonc,table,tsv,yaml,yamlc,none}]
            [--query JMESPATH] [--username USERNAME] [--password PASSWORD]
            [--service-principal] [--tenant TENANT]
            [--allow-no-subscriptions] [-i] [--use-device-code]
            [--use-cert-sn-issuer]
az login: error: 'issuer'

所以,我有2个问题.

  1. 为什么为环境值打印null?

  1. Why prints null for env values?

为什么出现此错误?,我阅读了

Why this error ?, I read the MSFT doc and command should be work fine. so, I don't know, What may be happening, null values are suspect...

推荐答案

我试图通过遵循 sh "部分使Azure CLI命令在适当的时候在azure应用程序服务上部署api(nodejs).有关此方面的更多信息,请参考a> Jenkins插件文章或 Jenkins博客

I have tried to reproduce your issue by following this Jenkins document but was successfully able to echo environment variables that are set. Regarding AZURE_DEV_PASSWORD variable in your case, I believe that its not better approach to have secure information like password in the pipeline so I would suggest you to just add an Azure service principal to Jenkins credential and then write an Jenkins pipeline script by having 'withCredentials([azureServicePrincipal('SERVICEPRINCIPALCREDENTIALID')])' and then by using 'sh' part to have Azure CLI command to deploy api(nodejs) on azure app service as appropriate. For more information with regards to it, please refer this Azure document or this Jenkins plugin article or this Jenkins blog.

希望这会有所帮助!干杯!

Hope this helps! Cheers!

这篇关于Jenkins Azure部署错误:az登录错误发布者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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