Search code examples
linuxgitjenkinsbitbuckethttp-status-code-403

Jenkins Error 128 / Git Error 403: Jenkins can't connect to my Bitbucket repository


OS: Ubuntu 16.04

Hypervisor: VirtualBox

Network configuration: Nat Network with port forwarding to access the vms through the host ip. I can also ping a VM from another VM.

I try to connect my Jenkins app hosted on a VM to my BitBucket server also on a VM. I followed a tutorial on internet but when i enter the address of my git repository i'm getting this:

Failed to connect to repository : Command "usr/bin/git ls-remote -h http://[email protected]:8005/scm/tes/repository-test.git HEAD" returned status code 128: stdout: stderr: fatal: unable to access 'http://[email protected]:8005/scm/tes/repository-test.git/': The requested URL returned error: 403

So, to be sure I tried to exectute the command on the terminal... and on the terminal it seems to work.. I can also push, clone, pull etc..

On this image you can see that it's true

Do you have an explanation?

EDIT:

I try some others things like use or not sudo to see if the permissions problem came from that and it seems that it's not the case. But I see that there is no result when we use the "HEAD" argument.

Do you think that because "HEAD" give no result, git in jenkins interprets it like no answer and returns the damn** error 403?

EDIT 2:

I found that on the web: http: // jenkins-ci.361315.n4.nabble.com/Jenkins-GIT-ls-remote-error-td4646903.html The guy has the same problem but in a different way, I will try to allocate more RAM to see if it does the trick.


Solution

  • I found the solution.

    I had to reinstall jenkins to have a user named "jenkins" with his own home directory.

    I don't know if it is linked or not, but I configured my bitbucket server to use only HTTPS with a self signed certificate (I work in lan)

    My troubleshoot was linked with my proxy settings. I disabled all my proxy settings in Linux so I was able to launch the command that did'nt worked in jenkins with terminal.

    I logged with sudo su jenkins the commands also worked. I found out that in the home directory of the jenkins user there was a "proxy.xml" file. I opened it and saw my old proxy settings. I deleted all the content with vim, saved and restarted and the error was gone.