因此,我找到了一个不理想的解决方案,它要求您在jenkins文件中指定凭据,而不是自动使用作业用于签出的凭据。
withCredentials([usernamePassword(credentialsId: 'bitbucketcreds', passwordVariable: 'GIT_PASS', usernameVariable: 'GIT_USER')]) {
sh "git config --global credential.helper '!f() { sleep 1; echo \"username=${env.GIT_USER}\\npassword=${env.GIT_PASS}\"; }; f'"
sh 'terraform init -input=false -upgrade'
sh 'git config --global --remove-section credential'
}
诀窍是使用
withCredentials
然后我用
this question
terraform init
--global
配置这里可能不是一个好主意,但对大多数人来说,是我所需要的,因为在我们的詹金斯代理怪癖。
如果有人有一个更顺利的方式做这件事,我会非常有兴趣听到它。