Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure GitLab repository in Jenkins

I'm trying to configure Jenkins (running on Windows Server 2008) to connect to a GitLab 6.0 repository (on a linux box).

From my local windows box I can use the SSH URLs to clone the projects on my GitLab server. I've had some issues using the HTTP URLs, but I did manage to connect using HTTP with authentication using the Eclipse plugin.

  • On the Jenkins project config screen I have attempted:

    http://myserver.domain/mygroup/myproject.git

Failed to connect to repository :

Command "d:\tools\Git\bin\git.exe ls-remote -h http://myserver.domain/mygroup/myproject.git HEAD"

returned status code 128:

stdout: stderr: error: The requested URL returned error: 504 while accessing

http://myserver.domain/mygroup/myproject.git/info/refs?service=git-upload-pack

fatal: HTTP request failed

When I try this URL in a browser I get an authentication popup. If I enter my email & password I can successfully download the list of branches & tags.

  • ...Okay, so I should be able to specify the username & password in the URL, right?

    http://username:[email protected]/mygroup/myproject.git

...nope:

http://username:[email protected]/mygroup/myproject.git/info/refs not valid: is this a git repository?

  • The Windows GUIs didn't have any trouble using SSH.
    ...Jenkins doesn't seem to like that much though:

    [email protected]:mygroup/myproject.git

    The error "Please enter Git repository" still remains, and when I attempt to save the config I see the following stack trace:

    Exception: java.lang.RuntimeException: Failed to instantiate class hudson.plugins.git.GitSCM from 
    {"value":"2",
     "userRemoteConfigs":     
       {"url":"[email protected]:mygroup/myproject.git",
        "name":"origin","refspec":""
       },
     "branches":{"name":""},
     "includedRegions":"","excludedRegions":"","excludedUsers":"",
     "localBranch":"","relativeTargetDir":"","reference":"",
     "scmName":"",
     "gitConfigName":"","gitConfigEmail":"",
     "pruneBranches":false,"skipTag":false,"clean":false,"remotePoll":false,
     "disableSubmodules":false,"recursiveSubmodules":false,
     "authorOrCommitter":false,"wipeOutWorkspace":false,"ignoreNotifyCommit":false,
     "useShallowClone":false,"":["","0"],
     "gitTool":"Default",
     "browser":{"stapler- class":"hudson.plugins.git.browser.FisheyeGitRepositoryBrowser"}
    
    Stacktrace:
    javax.servlet.ServletException: 
    java.lang.RuntimeException: Failed to instantiate class hudson.plugins.git.GitSCM from {...}
    at org.kohsuke.stapler.Stapler.tryInvoke(Stapler.java:725)
    ...
    Caused by: java.lang.RuntimeException: Failed to instantiate class hudson.plugins.git.GitSCM from {...}
      at hudson.model.Descriptor.newInstance(Descriptor.java:617)
      ...
    Caused by: java.lang.NullPointerException
      at hudson.scm.RepositoryBrowser.normalizeToEndWithSlash(RepositoryBrowser.java:85)
      at hudson.plugins.git.browser.FisheyeGitRepositoryBrowser.<init>(FisheyeGitRepositoryBrowser.java:37)
    
  • I tried adding the "ssh" protocol:

    ssh://[email protected]:mygroup/myproject.git

Jenkins immediately reacts:

stderr: ssh: myserver.domain:mygroup: no address associated with name

fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

like image 610
Nicholas Albion Avatar asked Nov 01 '22 15:11

Nicholas Albion


1 Answers

As I commented:

Maybe Jenkins doesn't support the scp syntax (with ':') Try

 ssh://[email protected]/mygroup/myproject.git

As mentioned in ".ssh config with amazon ec2 and git", using ':' usually involves a ~/.ssh/config file, which resolves the string preceding the ':' into a server, user, port and ssh key.

Jenkins might understand better [email protected]/mygroup/myproject.git instead of [email protected]:mygroup/myproject.git.

like image 108
VonC Avatar answered Nov 09 '22 06:11

VonC