【发布时间】:2019-03-02 18:55:24
【问题描述】:
我正在尝试使用 Jenkins Credential 插件连接到 github
withCredentials([usernamePassword(credentialsId: gitCredential, passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USERNAME')]) {
sh("git push https://${GIT_USERNAME}:${GIT_PASSWORD}@stash.abc.com:656/rad/abl/optical.git --tags")
}
我正在尝试推入 Git,但由于密码包含@而失败并出现以下错误。由于我们无法对从 Jenkins 凭据插件获得的密码进行 urlEncode。我正在寻找一种正确解析用户名和密码的方法。
[Tagging] Running shell script
+ git push 'https://****:****@stash.abc.com:656/rad/abl/optical.git' --tags
fatal: unable to access 'https://****:ZxmP*K@v6iO/?w4ms@stash.abc.com:656/rad/abl/optical.git': Couldn't resolve host 'v6iO'
[Pipeline] }
[Pipeline] // withCredentials
任何意见都会有所帮助。
谢谢!
【问题讨论】:
-
哦,凭证密码中的特殊字符似乎是一个常见的烦人问题。如果您将源设置为您的推送 URL 并使用 git 凭证助手,这会给您带来任何好处吗?我还没有尝试过,所以觉得我不能把它作为答案。这里有一些细节值得一看:alanedwardes.com/blog/posts/…
-
谢谢@macg33zr,这确实有帮助:)
标签: jenkins groovy jenkins-plugins jenkins-pipeline