Git 如何在Jenkins的url中传递credentialID

Git 如何在Jenkins的url中传递credentialID,git,jenkins,Git,Jenkins,我正在使用此命令: sh 'git push https://${userid}:${passwd}@innersource.com/scm/raghu/demo.git' 但是我想使用-credentialsId:'f0079d43-9522-4133-9601-89c81f8ce7c9',而不是id和密码,我想在URL()中传递credentialsId 我该怎么做 environment { NEXUS_REPO = credentials('nexus-repo-credent

我正在使用此命令:

sh 'git push https://${userid}:${passwd}@innersource.com/scm/raghu/demo.git'
但是我想使用-credentialsId:'f0079d43-9522-4133-9601-89c81f8ce7c9',而不是id和密码,我想在URL()中传递credentialsId

我该怎么做

environment {
    NEXUS_REPO = credentials('nexus-repo-credentials')
    GITHUB_AUTH_TOKEN = credentials('jx-release-version-github-token')
    GITHUB_REPO = 'demo'
}
在stage下的步骤中,您可以使用

sh "git remote set-url origin git@github.com:innersource.com/scm/raghu/${GITHUB_REPO}.git"
在stage下的步骤中,您可以使用

sh "git remote set-url origin git@github.com:innersource.com/scm/raghu/${GITHUB_REPO}.git"

您可以在管道阶段将凭证绑定插件
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
将变量设置为凭据中给定的用户名和密码,以冒号(:)分隔


您可以在管道阶段将凭证绑定插件
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
将变量设置为凭据中给定的用户名和密码,以冒号(:)分隔