在我们的jenkins构建期间,我们正在尝试推送到git。我们的密码最近更改了,现在包括一个@符号,它给出了以下错误:
建议似乎是对密码进行编码,但我不知道如何在我们的jenkins管道中做到这一点。我该怎么做呢?(我还尝试使用replace方法将@符号替换为%40,但不起作用。)
def GIT_PASSWORD_R = GIT_PASSWORD.replace('@', '%40') Escape @ character in git proxy password
def GIT_PASSWORD_R = GIT_PASSWORD.toURL()
git push -f https://${GIT_USERNAME}:${GIT_PASSWORD_R}@github.company.com/Product/subProd.git ${VERSION}-SNAPSHOT发布于 2019-08-15 21:43:36
我也遇到过同样的问题。与编码相比,另一个对我有效的选择是使用git凭证帮助器。请看这个答案:https://stackoverflow.com/a/40038869/9463800
它设置一个git凭证帮助器,执行git操作,并在finally块中取消设置密码。
try {
withCredentials([[$class: 'UsernamePasswordMultiBinding', credentialsId: 'MyID', usernameVariable: 'GIT_USERNAME', passwordVariable: 'GIT_PASSWORD']]) {
sh("${git} config credential.username ${env.GIT_USERNAME}")
sh("${git} config credential.helper '!echo password=\$GIT_PASSWORD; echo'")
sh("GIT_ASKPASS=true ${git} push origin --tags")
}
} finally {
sh("${git} config --unset credential.username")
sh("${git} config --unset credential.helper")
}https://stackoverflow.com/questions/57506821
复制相似问题