1. 程式人生 > >gitblit與jenkins整合推送構建通知

gitblit與jenkins整合推送構建通知

<p>##gitblit與jenkins推送整合</p><p>來源:https://voat.co/v/programming/comments/372494

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.

Usage scenario

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.

Gitblit

Easy setup
Integrates well with Jenkins
Lightweight - compared to Allura or Gitlab
Lacks self registration functionality for users

Jenkins CI

Easy setup
Robust plugin community
It's what Circle CI, Travis CI uses for their base stack.

Steps:

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.
</p><p>##Restart gitblit.
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>

Restart Jenkins.

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>



作者:xzs63
連結:https://www.jianshu.com/p/3a329801a078
來源:簡書
簡書著作權歸作者所有,任何形式的轉載都請聯絡作者獲得授