4
votes

I'm a relative novice with Jenkins and am trying to simply run a build from code stored on Bitbucket. I am using git. I have setup the job source control as https protocol as: url: https://[email protected]/myaccount/myrepo.git credentials: username/password

the 'build' section points to the pom.xml in the root and runs the clean test maven goal

I have the Git plugin 2.5.2

I am running Jenkins as a Windows service (Windows 10).

The error on building the project is

ERROR: Timeout after 10 minutes

git.exe config --local --remove-section credential # timeout=10 ERROR: Error fetching remote repo 'origin' hudson.plugins.git.GitException: Failed to fetch from https://[email protected]/username/myrepo.git at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:799) at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1055) at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1086) at hudson.scm.SCM.checkout(SCM.java:495) at hudson.model.AbstractProject.checkout(AbstractProject.java:1270) at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:604) at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:86) at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:529) at hudson.model.Run.execute(Run.java:1720) at hudson.maven.MavenModuleSetBuild.run(MavenModuleSetBuild.java:531) at hudson.model.ResourceController.execute(ResourceController.java:98) at hudson.model.Executor.run(Executor.java:404) Caused by: hudson.plugins.git.GitException: Command "git.exe -c core.askpass=true fetch --tags --progress https://[email protected]/username/myrepo.git +refs/heads/:refs/remotes/origin/" returned status code -1:

Any advice welcome

2
It's highly possible git asks for password in spite of not being allowed to (non-interactive shell), and this is a private repo. You need to somehow provide the password some other way.Paul Stelian
Are you able to ping bitbucket.org from a build step in your job?Rogério Peixoto

2 Answers

2
votes

as I answered here https://stackoverflow.com/a/43964812/908936 :

try to disable use of the git credential cache using

git config --global --unset credential.helper

You may also need to do

git config --system --unset credential.helper if this has been set in the system config file
0
votes

Any specific reason for using username/password for accessing the repo?

Another way that is more convenient and secure is to use ssh. Follow these steps: If not already done, generate a rsa key in your Jenkins server for the user that you are using to access bitbucket.

sudo su <bitbucket user> #if such user not already created, create it first.  
ssh-keygen 

Press enter for every question asked.

Now got to the hidden .ssh directory in home and copy the public key that you need to paste in bitbucket keys in next step.
vi ~/.ssh/id_rsa.pub

Now login to the same bitbucket account and go to: User Profile -> Setting -> Security -> SSH keys and paste here the public key copied in (2). In your scripts and settings, replace the 'http' in your bitbucket url with 'ssh'

Now try again and it should work.