How to setup Gitblit and integrate it with Jenkins CI to build your projects as you push them to repo (programming)
Gitblit is a pure Java based git solution. It falls under one of the forge softwares like Apache Allura that combines ticketing system with web ui for git. I went through a process of setting it up and I thought I can help new users avoid the pain points.
You want to self-host git repos
You want to setup a Jenkins server to take git repo pushes and run build tests on those branches.
You have a domain name and you can set the A Record for it.
Integrates well with Jenkins
Lightweight - compared to Allura or Gitlab
Lacks self registration functionality for users
Robust plugin community
It's what Circle CI, Travis CI uses for their base stack.
Download Gitblit from http://gitblit.com/
For most people you'll want the Gitblit GO.
Follow the installation instructions on the site
Configure the gitblit.properties file in /data directory. Be sure to fill in web.canonicalUrl - it needs to be set for Jenkins integration to work properly.
Download and install Jenkins from http://jenkins-ci.org/
Setup Jenkins as described in https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins
If you installed it as a daemon, launch it ( /etc/init.d/jenkins start )
Go to the url for jenkins. go to Manage Jenkins -> Configure Global Settings -> Enable Security
Turn on 'Allow Users to Signup'
Register and then turn 'Allow Users to Signup' off.</p><p>##推送配置</p><p>At this point you have both Gitblit and Jenkins set up. But they aren't interacting yet. We want to make it so when we push the commits to gitblit, Jenkins builds it. ###Go to the settings in a repo already in your gitblit site.</p><p>### Go to the 'receive' section of the repo setting and add jenkins to the 'selected' column in the 'post-receive scripts' sub-section. </p><p>##Go to the /data/groovy directory of Gitblit in your server, edit the jenkins.groovy file.Under jenkinsUrl input your jenkins url.
Login to Jenkins web ui. Go to 'Manage Plugins.' Click on 'Available' and type in Git Plugin into the search box. Install that.</p><p>
Also in the plugins are the build environment support plugins. Add those. Specifically for NodeJS, you juse have to be aware that NodeJS plugin's Auto Installation does not show NodeJS dropdown. You have to install by inputting the url of where tar.gz exists. Input the subdirectory that would exist if you unpack it.
Go to Manage Jenkins -> Configure System.
Add the proper build environment pre-sets. This is specific to what you want to do. So I leave this out.
Finally, add your build. 'New Item' -> 'Freestyle'
Select git from 'Source Code Management' section. Put the url and other settings. I usually have two build projects made for each git project. One for -Release, and one for -All. I set it up so the branch setting in Jenkins is blank for -All project. That way all feature and dev branches are built and tested.
Next, select 'Poll SCM' and leave it blank. Gitblit's Jenkins groovy plugin will call the Jenkins' hook for building on-demand this way. A way to verify is to try curl /git/notifyCommit?url=/r/ or you can also just put that in the browser as well.
If you want links to those cool 'build status' image as well, install embeddable-build-status plugin for Jenkins. After that, link it in your website or markdown docs.
Congratulations, you now have Gitblit and Jenkins CI set up to take the git commit pushes and build them!</p>