Статья написана для Hudson, но для Jenkins все идентично, только вместо
jenkins :) Еще на инглише, т.к. писал для внутреннего вики. Со временем переведу, хотя уже пол года в черновиках лежит.
$ wget -O - http://hudson-ci.org/debian/hudson-ci.org.key | sudo apt-key add - $ sudo echo "deb http://hudson-ci.org/debian binary/" >> /etc/apt/sources.list $ sudo apt-get update $ sudo apt-get install hudson
Also you should install OpenJDK if it is not installed yet:
sudo apt-get install openjdk-6-jre-headless
So after this:
- Hudson will be launched as a daemon up on start. See /etc/init.d/hudson for more details.
- The 'hudson' user is created to run this service.
- Log file will be placed in /var/log/hudson/hudson.log. Check this file if you are troubleshooting Hudson.
- /etc/default/hudson will capture configuration parameters for the launch.
Now you can visit UI in 127.0.0.1:8080 to check it is working. Visit Manage Hudson>Manage Plugins>Available and install Git Plugin, Cobertura Plugin. Restart Hudson:
$ sudo /etc/init.d/hudson restart
CONFIGURE EMAIL SENDING
Visit Manage Hudson>Configure System. At the bottom you can see E-mail Notification. For python SMTP server(python -m smtpd -n -c DebuggingServer localhost:1025) I have this:
For Gmail something like this:
Click "Test configuration by sending e-mail to System Admin Address" for testing.
CONFIGURE IRC SENDING
Install IRC Plugin. Now you can see "IRC Notification" section in Hudson settings. Example of settings:
I changed Nickname because default was not available, don't know why. Now restart Hudson and it should join IRC channel. In project settings enable " IRC Notification" and set channel you add in Hubson settings("#universalsubtitles"). If you have problem check logs. You can find them on Settings page.
All is described HERE
To allow some other user edit project settings visit Manage Hudson->Configure System->Access Control->Project-based Matrix Authorization Strategy. Then in project settings chose Enable project-based security and add new user.
"Delete yourself from the $HUDSON_HOME/users directory.
This lets you recreate yourself as a user. Once you've recreated yourself as a user, you're an administrator since you already exist in the Hudson $HUDSON_HOME/config.xml file as an administrator. "
$HUDSON_HOME for me is /var/lib/hudson/. Maybe you need stop Hudson at first: sudo /etc/init.d/hudson stop To start again: sudo /etc/init.d/hudson start
ADD JOB FOR PROJECT INSTALL
Create new job, select Source Code Management - Git, add link to repo somethin like: git://github.com/8planes/mirosubs.git. Click Save at the bottom and Build Now. This should be all, but I got error:
FATAL: Could not apply tag hudson-Install-1 *** Please tell me who you are. Run git config --global user.email "email@example.com" git config --global user.name "Your Name" to set your account's default identity. Omit --global to set the identity only in this repository. fatal: empty ident <hudson@alerion-K50IN.(none)> not allowed
So go to the workspace folder, at the top of console output you can find something like this: Checkout:workspace / /var/lib/hudson/jobs/Install/workspace - hudson.remoting.LocalChannel@1b7516d
$ cd /var/lib/hudson/jobs/Install/workspace $ git config user.email "firstname.lastname@example.org" $ git config user.name "hudson"
I fount this recipe here.
Now build job again. After finish you can see workspace through the Hudson UI.
INSTALLING ENVIRONMENT AND RUNNING TESTS
Create script for building virtual environment and for testing. All this is described HERE.
What problems I have got:
- source command was not found so I changed source ./ve/bin/activate to . ./ve/bin/activate
- if set in requirements link to git repo and point to certain commit - pip can't run git pull, so I change just to branch.
Example of build script
cd $WORKSPACE virtualenv -q env . ./env/bin/activate pip install -q -E ./env -r requirements.txt pip install -q -E ./env -r requirements-test.txt python manage.py test auth --settings=test_settings --with-coverage --cover-package=videos --with-xunit --with-xcoverage
We test just auth application. You can use example from article above.
This is requirements for testing tools, which can generate coverage and test result reports in Hudson-friendly format.
coverage==3.2b3 nose git+git://github.com/cmheisel/nose-xcover.git#egg=nosexcover django-nose pylint
After first success building we can add reports for displaying in Hudson. We can do it before, but really can see something only if Hudson have at list one completed building. So in Job's settings we should set this settings: