Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure port for git repository in jenkins

I am trying to create a Maven project in Jenkins. The code is in Git repository which uses non standard port 1754.

The port details are already there in the config file but the git plugin in jenkins is not able to connect. It is giving error for port 22.

Following error is coming in Jenkins (Git section) after adding following url: [email protected]:AutomationCode

  Failed to connect to repository : Command "/usr/bin/git -c 
  core.askpass=true ls-remote -h [email protected]:AutomationCode 
  HEAD" returned status code 128:
  stdout: 
  stderr: ssh: connect to host 10.115.2.110 port 22: Connection refused 
  fatal: Could not read from remote repository.
  Please make sure you have the correct access rights
  and the repository exists.

When I cloned the git repository directly from terminal it is working fine but in Jenkins it is not using the config file for port.

I tried giving ssh URL but it is also not working. "Connection refused" error is coming. I tried giving fixed port number in Manage Jenkins -> configure system page in SSH Server section. But still issue is unresolved.

Is there any way by which we can configure a project to use specific port in Jenkins -> Git or maybe access the .ssh/config file to take the port number ?

I am using SSH Keys to access the git.

like image 889
Shashank Avatar asked Nov 10 '22 20:11

Shashank


1 Answers

If you are cloning from the command line using the same url ([email protected]:AutomationCode), then:

  • you are using the port 22 (standard for ssh), or as noted below, a ~/ssh/config file with an "Host gitolite" entry.
  • you might not be using the same ~/.ssh with Jenkins as you are in command line with your account.

Make your Jenkins jobs print 'env' to see if the environment variable (and username) are the same as the ones you would see in your terminal.

like image 162
VonC Avatar answered Nov 15 '22 05:11

VonC