简体   繁体   中英

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://admin@192.168.6.102:8005/scm/tes/repository-test.git HEAD" returned status code 128: stdout: stderr: fatal: unable to access 'http://admin@192.168.6.102: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.

There could be many possible problems, but you are getting 403 - Access Forbidden, which indicates some problem with permissions. I would suggest first common mistakes:

  • a) trying https instead http - my scm only uses https,
  • b) check if admin is correct - scm by default uses scmadmin.

Here I run the exact same command twice.

The first time I used the proxy configuration wich I need to access internet, and the second time I set the mandatory server on "none".

So there is a problem with the damn proxy. I was thinking that the proxy was not used in NAT connection with VirtualBox...

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.

there can be git version miss match..... I would suggest you update git once. maybe it will resolve your issues.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM