在詹金斯(Jenkins)多分支管道中注入秘密
我有具有管理员访问权限的本地jenkins设置.
I have local jenkins setup with admin access.
我已按照 https://support.cloudbees.com/hc/zh-CN/articles/203802500-Injecting-Secrets-into-Jenkins-Build-Jobs .
尽管如此,我仍然不清楚如何在詹金斯(Jenkins)多分支管道工作中注入秘密.我看不到任何配置选项来设置环境变量. PS-我不想在git中提交秘密;)
Though, I am still unclear about how to inject secrets in Jenkins multibranch pipeline jobs. I could not see any configurations option to either set the environemntal variables as well. PS - I do not want to commit secrets in git ;)
需要将它们作为詹金斯的秘密注入.
Need to inject them as secrets from Jenkins.
我使用凭据插件存储凭据和凭据绑定插件将它们映射到环境变量.这是我的操作方式:
I used credentials plugin to store credentials and credentials binding plugin to map them to environmental variables. Here is how I did it:
withCredentials([string(credentialsId: 'AZURE_SUBSCRIPTION_ID', variable: 'AZURE_SUBSCRIPTION_ID')]) {
}
withCredentials([string(credentialsId: 'AZURE_CLIENT_ID', variable: 'AZURE_CLIENT_ID')]) {
}
withCredentials([string(credentialsId: 'AZURE_TENANT_ID', variable: 'AZURE_TENANT_ID')]) {
}
withCredentials([string(credentialsId: 'AZURE_CLIENT_SECRET', variable: 'AZURE_CLIENT_SECRET')]) {
}