Use gitlist as git repository browser in Jenkins

Use gitlist as git repository browser in Jenkins

Jenkins git-scm plugin provides support for various git repo browser applications, but the wonderful gitlist isn’t one of them…
Still I found you can fool Jenkins into using gitlist as your repository browser.
(We’ve been using gitlist on one of the ALM environments I manage and gitLab on another one. At some stage I noticed that gitLab‘s commit url is build exactly the same as a commit url in gitlist  : <gitlist_url>/<repo-name>.git/commit/<commit_hash> vs. <gitlab_url>/<repo_name(without .git extension)>/commit/<commit_hash>.
Actually what jenkins git plugin does when constructing the repository browser link for gitlab is add the ‘commit/<commit_hash>’ on top of gitlab project url. And it works perfectly fine for gitlist too!)

To use gitlist as your git repo browser in Jenkins:

in git plugin define the following:

Repository browser : gitlab

URL: <your gitlist url (repo name with .git)> (eg: http://gitserver/gitlist/myRepo.git)

Version: 5.4

Now for every commit in the changes list on build page you’ll get a ‘gitlab’ link which will lead you to the commit page on gitlist.

I relaize it is quite easy to add this support to the plugin itself and get the correctly named ‘gitlist’ link, but until I or someone else find time for that – this is a nice workaround.

and here’s a groovy script to set this for all your git jobs:

[sourcecode language=”groovy”]

import hudson.model.*;
import hudson.plugins.git.*
import hudson.plugins.git.browser.*

//replace with your own values
def view = Hudson.instance.getView("myViewName")
def myRepoUrl = "http://gitserver/gitlist/myRepo.git"

for(item in view.getItems())
{

def SCM = item.getScm()
if(SCM instanceof GitSCM ) {
println (item.getName());
def browser = SCM.getBrowser();
if (browser){
println browser.getUrl()
}
else
{
browser = new GitLab( myRepoUrl, "5.4");
SCM.browser = browser
}
}
}
[/sourcecode]

Enjoy!

//