Injecting secrets in Jenkins multibranch pipeline

不打扰是莪最后的温柔 提交于 2019-12-13 00:33:43

问题


I have local jenkins setup with admin access.

I have configured plugins as per this https://support.cloudbees.com/hc/en-us/articles/203802500-Injecting-Secrets-into-Jenkins-Build-Jobs.

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.


回答1:


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')]) {
}


来源:https://stackoverflow.com/questions/45007850/injecting-secrets-in-jenkins-multibranch-pipeline

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!