将密码作为环境变量注入到构建中

将密码作为环境变量注入到构建中,第1张

将密码作为环境变量注入到构建中

@daspilker和@JesseGlick,非常感谢您的回复。它帮助我用Jenkins编写了我的第一个configure块。提及我的行为,以便对其他面临相同问题的人有所帮助。

由于我们正在使用Job DSL 1.27,因此我无法直接使用凭据绑定。因此创建了一个configure块,并通过我的.groovy脚本注入了所需的变量。

注意:如果收到“找不到credentialsId”错误,则需要从“ * / job / config.xml”获取“
credentialsId”的转换值。

static def credentialsBinding = { String userNameVar, String passwordVar, String credId, wrapperContext ->    def nodeBuilder = new NodeBuilder()    wrapperContext.wrapperNodes << nodeBuilder.'org.jenkinsci.plugins.credentialsbinding.impl.SecretBuildWrapper'(plugin: "credentials-binding@1.4") {        bindings { 'org.jenkinsci.plugins.credentialsbinding.impl.UsernamePasswordMultiBinding' {     usernameVariable userNameVar     passwordVariable passwordVar     credentialsId credId }        }    }}


欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/zaji/5002113.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-11-14
下一篇2022-11-14

发表评论

登录后才能评论

评论列表(0条)

    保存