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
来源:简书
简书著作权归作者所有,任何形式的转载都请联系作者获得授权并注明出处。

转载于:https://my.oschina.net/u/4000302/blog/3051333

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值