在詹金斯(Jenkins)多分支管道中注入秘密 [英] Injecting secrets in Jenkins multibranch pipeline

查看:175
本文介绍了在詹金斯(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')]) {
}

这篇关于在詹金斯(Jenkins)多分支管道中注入秘密的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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