大佬教程收集整理的这篇文章主要介绍了如何在Jenkins Pipeline中的withCredentials中使用多个凭据,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
当然,您可以使用一个withCredentials
块将多个凭证分配给不同的变量。
withCredentials([
usernamepassword(credentialsID: credsID1, usernameVariable: 'USER1', passwordVariable: 'PASS1'),
usernamepassword(credentialsID: credsID2, usernameVariable: 'USER2', passwordVariable: 'PASS2')
]){
//...
}
我在声明性jenkins管道中执行以下步骤:我resources/
使用libraryresource
创建来自文件夹的脚本。该脚本包含我的autobuild
用户和某些admintest
用户的凭据。
stage('Build1') {
steps {
node{
def script = libraryresource 'tests/test.sh'
writeFile file: 'script.sh',text: script
sh 'chmod +x script.sh'
withCredentials([usernamepassword(credentialsId: xxx,usernameVariable: 'AUTOBUILD_USER',passwordVariable: 'AUTOBUILD_PASSWD')]){
sh './script.sh "
}
}
}
这很好。我可以使用我的autobuild
用户。现在,我正在寻找最好的方式来包括admintest
用户的凭据。我是否需要“嵌套”第二withCredentials
部分,还是可以再次添加usernamepassword
“数组”?
以上是大佬教程为你收集整理的如何在Jenkins Pipeline中的withCredentials中使用多个凭据全部内容,希望文章能够帮你解决如何在Jenkins Pipeline中的withCredentials中使用多个凭据所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。