使用 GIT_ASKPASS 推回 Jenkinsfile 中的 git repo

Tom*_*hof 8 jenkins-pipeline

有没有办法推回 Jenkins 管道使用与检出代码相同的过程(使用GIT_ASKPASS)检出的存储库?

我目前有一个解决方案,可以通过获取这样的凭据来实现这一点:

withCredentials([usernamePassword(credentialsId: 'github', passwordVariable: 'GIT_PASS', usernameVariable: 'GIT_USER')]) {
  sh('git push https://$GIT_USER:$GIT_PASS@github.com/orgname/private-repo.git master')
}
Run Code Online (Sandbox Code Playgroud)

我不是 Groovy 开发人员,但在 git-client-plugin 中找到了一个我想使用的方法。有没有办法直接在下面的方法中使用Jenkinsfile

launchCommandWithCredentials

https://github.com/jenkinsci/git-client-plugin/blob/master/src/main/java/org/jenkinsci/plugins/gitclient/CliGitAPIImpl.java#L1649