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:password@myserver.domain/mygroup/myproject.git

…nope:

http://username:password@myserver.domain/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:

    git@myserver.domain: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":"git@myserver.domain: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://git@myserver.domain: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.

  • Using the jenkins CLI (on fedora 23)
  • Grunt integration with Jenkins on windows issue
  • Ivy, Ant, Jenkins - Is it good idea to to a <ivy:cleancache> on Jenkins builds?
  • Hudson: How to pass parameters to shell script
  • Upgrade SonarQube issues
  • How to update Jenkins config.xml from Java code?
  • maven deploy to tomcat cluster (multiple) in one line
  • The bucket you are attempting to access must be addressed using the specified endpoint , while uploading from jenkins to s3
  • One Solution collect form web for “Configure GitLab repository in Jenkins”

    As I commented:

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

     ssh://git@myserver.domain/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 git@myserver.domain/mygroup/myproject.git instead of git@myserver.domain:mygroup/myproject.git.

    Git Baby is a git and github fan, let's start git clone.