I know that if I add the crdentialsId, it will work, like:
fileLoader.fromGit('script_to_call', 'https://bitbucket.org/myproje
ct/script-repo.git', 'master', xxxxx-xxxxx-xxxxxxx)
But I just don't want it in my source code on bitbucket, and there is no
parent job.I also tried to create the Global Environment Variable in Jenkins, but how can I pass it to fileLoader.fromGit()? On Mon, Dec 19, 2016 at 2:50 PM, Mark Waite <[email protected]> wrote: > You'll somehow need to pass the credentialsId to the git (or checkout) > task. One way might be to assign the values extracted from the file you're > reading to a groovy string, then pass the expansion of that string ( > "${repository_url}" ) to the git command (or the checkout command) along > with the credentialsId from the parent Jenkins job. > > Mark Waite > > On Mon, Dec 19, 2016 at 12:34 PM <[email protected]> wrote: > >> 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-QWL4DG3IFZJ6ZBQ2RI2QCTE4TJEXJ3 >> XEKPIAKUG2LIUSXZOX2CVA >> [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/' >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Jenkins Users" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit https://groups.google.com/d/ >> msgid/jenkinsci-users/e055d665-c918-40fe-8c85- >> 2fb5a70bb3e5%40googlegroups.com >> <https://groups.google.com/d/msgid/jenkinsci-users/e055d665-c918-40fe-8c85-2fb5a70bb3e5%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to a topic in the > Google Groups "Jenkins Users" group. > To unsubscribe from this topic, visit https://groups.google.com/d/ > topic/jenkinsci-users/_MTcjLNyPTU/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit https://groups.google.com/d/ > msgid/jenkinsci-users/CAO49JtEu%2BTuBO-5X85-ipJyLdOEqVwYLCdEvFBnCiNvKTPP8c > Q%40mail.gmail.com > <https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtEu%2BTuBO-5X85-ipJyLdOEqVwYLCdEvFBnCiNvKTPP8cQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAGY7CS_eTkp48ON1GtyQQ0xYyXdnhnh6Snfp4xOOXuLkZaqYiA%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
