我正在使用以下命令:
sh 'git push https://${userid}:${passwd}@innersource.com/scm/raghu/demo.git'
但是我想使用-凭据ID:'f0079d43-9522-4133-9601-89c81f8ce7c9',而不是ID和密码,我想在URL(https://innersource.com/scm/raghu/demo.git)中传递凭据ID
我该怎么做?
答案 0 :(得分:0)
environment {
NEXUS_REPO = credentials('nexus-repo-credentials')
GITHUB_AUTH_TOKEN = credentials('jx-release-version-github-token')
GITHUB_REPO = 'demo'
}
可以逐步使用
sh "git remote set-url origin git@github.com:innersource.com/scm/raghu/${GITHUB_REPO}.git"
答案 1 :(得分:0)
您可以在管道阶段将凭据绑定插件与usernameColonPassword
属性一起使用。这还将在控制台日志中将凭据屏蔽为****
。
stage(git-push) {
withCredentials([usernameColonPassword(credentialsId: 'f0079d43-9522-4133-9601-89c81f8ce7c9', variable: 'USERPASS')]) {
sh 'git push https://${USERPASS}@innersource.com/scm/raghu/demo.git'
}
}
usernameColonPassword
将凭据中指定的用户名和密码设置为变量,并用冒号(:)分隔。