Firstof, my company won't allow SSH connection to the
bitbucket.org site and any other. So I have to use HTTPS for checkout scm in a multibranch pipeline project. It works perfect when the main repo is cloned by HTTPS and by using the
bitbucket.org credential. But my main repo has a Jenkinsfile that will checkout another repo under the same project which contains a bunch of other groovy scripts. Then it threw out an error message and "git clone" will just fail. (If I change it to use SSH, it will work.)
The error message is:
"ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress
https://bitbucket.org/myproject/scripts-repo.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: remote: Invalid username or password. If you log in via a third party service you must ensure you have an account password set in your account profile.
My Jenkinsfile contains the following, and will check out the script-repo by HTTPS(As said SSH will work here):
fileLoader.fromGit('script_to_call', '
https://bitbucket.org/myproject/script-repo.git', 'master')
So how can I enable "using GIT_ASKPASS to set credentials" in this Jenkinsfile so that it will use the same bitbucket credential that was being used for the main repo check out?
thanks for anyone's help.
Here is the full logs when building:
Started by user J
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url
https://bitbucket.org/myproject/mainrepo.git # timeout=10
Fetching upstream changes from
https://bitbucket.org/myproject/mainrepo.git.git > git --version # timeout=10
using GIT_ASKPASS to set credentials bitbucket cred within pipeline domain
> git fetch --tags --progress
https://bitbucket.org/myproject/mainrepo.git +refs/heads/master
Checking out Revision 37e755bd6e51b66450ee39de9ad70ab6a8ba950c (master)
> git config core.sparsecheckout # timeout=10
> git checkout -f 37e755bd6e51b66450ee39de9ad70ab6a8ba950c
> git rev-list 37e755bd6e51b66450ee39de9ad70ab6a8ba950c # timeout=10
[Bitbucket] Notifying commit build result
[Pipeline] node
Running on master in /var/lib/jenkins/workspace/h-pipeline-example_master-QWL4DG3IFZJ6ZBQ2RI2QCTE4TJEXJ3XEKPIAKUG2LIUSXZOX2CVA
[Pipeline] {
[Pipeline] dir
Running in /var/lib/jenkins/workspace/h-pipeline-example_master-QWL4DG3IFZJ6Q2RI2QCTE4TJEXJ3XEKPIAKUG2LIUSXZOX2CVA/libLoader
[Pipeline] {
[Pipeline] deleteDir
[Pipeline] echo
Checking out
https://bitbucket.org/myproject/script-repo.git, branch=master
[Pipeline] checkout
Cloning the remote Git repository
Cloning repository
https://bitbucket.org/myproject/script-repo.git > git init /var/lib/jenkins/workspace/h-pipeline-example_master-QWL4DG3IFZJ6ZBQ2RI2QCTE4TJEXJKPIAKUG2LIUSXZOX2CVA/libLoader # timeout=10
Fetching upstream changes from
https://bitbucket.org/myproject/script-repo.git > git --version # timeout=10
> git fetch --tags --progress
https://bitbucket.org/myproject/script-repo.git +refs/heads/*:refs/remotes/origin/*
ERROR: Error cloning remote repo 'origin'
hudson.plugins.git.GitException: Command "git fetch --tags --progress
https://bitbucket.org/myproject/script-repo.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout:
stderr: remote: Invalid username or password. If you log in via a third party service you must ensure you have an account password set in your account profile.
fatal: Authentication failed for '
https://bitbucket.org/myproject/script-repo.git/'