11

I am trying to setup Jenkins with BitBucket GIT repository, but the Jenkins console always gives me this error code:

Started by user Dakado
Building in workspace /var/lib/jenkins/workspace/TEST852
Fetching changes from the remote Git repository
Fetching upstream changes from git://bitbucket.org/GameTeamCZ/gtplaytime.git
FATAL: Failed to fetch from git://bitbucket.org/GameTeamCZ/gtplaytime.git
hudson.plugins.git.GitException: Failed to fetch from git://bitbucket.org/GameTeamCZ/    gtplaytime.git
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:625)
at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:847)
at hudson.plugins.git.GitSCM.checkout(GitSCM.java:872)
at hudson.model.AbstractProject.checkout(AbstractProject.java:1411)
at hudson.model.AbstractBuild$AbstractBuildExecution.defaultCheckout(AbstractBuild.java:651)
at jenkins.scm.SCMCheckoutStrategy.checkout(SCMCheckoutStrategy.java:88)
at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:560)
at hudson.model.Run.execute(Run.java:1670)
at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
at hudson.model.ResourceController.execute(ResourceController.java:88)
at hudson.model.Executor.run(Executor.java:231)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git://    bitbucket.org/GameTeamCZ/gtplaytime.git +refs/heads/*:refs/remotes/origin/*"     returned status code 128:
stdout: 
stderr: bitbucket.org[0: 131.103.20.167]: errno=Connection timed out
bitbucket.org[0: 131.103.20.168]: errno=Connection timed out
fatal: unable to connect a socket (Connection timed out)

at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:1148)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:1018)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.access$200(CliGitAPIImpl.java:74)
at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:207)
at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:623)
... 10 more

I have tried it many different ways but it always fails. Traffic on port 9418 is allowed on my server. Server is on 1 Gbps connection.

Dakado
  • 123
  • 1
  • 2
  • 9
  • I have the same issue on my Jenkins instance on Docker. When I try to clone repo with the same SSH key from the same workspace in the terminal it works perfectly but running Jenkins job it trowing error `Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --progress git@gitlab.domain.com:SomeName/repo-name.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:` – Lyserty Oct 11 '18 at 04:58
  • Possible duplicate of [Why is Jenkins failing when fetching from git, while the command line isn't?](https://stackoverflow.com/questions/24813816/why-is-jenkins-failing-when-fetching-from-git-while-the-command-line-isnt) – kenorb Jul 29 '19 at 22:34

4 Answers4

3

Your issue is right here :

Fetching upstream changes from git://bitbucket.org/GameTeamCZ/gtplaytime.git
FATAL: Failed to fetch from git://bitbucket.org/GameTeamCZ/gtplaytime.git

Is your repository public or private ? If it is private, then there is 2 ways to connect to your Repo :

First using login/password

https://**login:password**@bitbucket.org/GameTeamCZ//gtplaytime.git

Second using CREDENTIALS Refer to that page to setup credentials for your Jenkins server : https://confluence.atlassian.com/display/BITBUCKET/Set+up+SSH+for+Git

Then you can use a command like that to login to your repository:

git@CREDENTIALS:TEAM/REPO.git
aorfevre
  • 4,934
  • 3
  • 20
  • 51
2

This is worked for me: You need to create App Password on Bitbucket

(1) go to BitBucket Setting-> Access Manaegment-> App passwords-> Repositories (select options here whatever you want to accomplish)

(2) Jenkins -> Credentials-> Jenkins-> Global credentials (unrestricted) -> Add Credentials -> Kind "Username with password" provide here user/password here

(3) Go to your Jenkins Jobs -> GIT ->
Repository URL : https://USER_NAME@bitbucket.org/ABCcompany/myRepo.git Credentials: select from dropdown You just created

Resources: Bitbucket, Jenkins, Selenium, Chrome

Mike ASP
  • 1,513
  • 1
  • 16
  • 21
1

Increasing the clone time works for me. My clone was terminating as the file was too large and required more time to fetch the code from the repository and the default timeout is set at 10 minutes. Hence, increasing the limit from 10 to a larger time limit worked for me. Go to the job > Configure > Source Code Management > click on Add Additional Behaviours > select Advanced Clone Behaviour > set 'Timeout (in minutes) for clone and fetch operations' to 100. and check on Shallow Clone with depth 1. Check the attached image for more clarity here - JENKINS configuration for clone behaviour

1

So I have been struggling with this issue for months now. And after finding this thread, I finally got a successful pull and build.

My solution. I changed my settings from trying to pull with SSH and used what Mike ASP suggested. I used user name/pw as a global credentials.

There may have been a step missing on my configuration trying to pull using SSH. But the username and password works like a charm.

Deuces
  • 11
  • 2
  • 1
    This does not provide an answer to the question. Once you have sufficient [reputation](https://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](https://stackoverflow.com/help/privileges/comment); instead, [provide answers that don't require clarification from the asker](https://meta.stackexchange.com/questions/214173/why-do-i-need-50-reputation-to-comment-what-can-i-do-instead). - [From Review](/review/late-answers/29844478) – Robert Sep 16 '21 at 21:13