This repository contains the code (config, src and script files) to set up and run a Cob-Jenkins-CI-Server using the Cob-Pipeline-PlugIn.
Install the Operating System of your choice for your Server.
Supported OS:
- Windows
- Debian/Ubuntu
- Red Hat/Fedora/CentOS
- MacOS X
- openSUSE
- FreeBSD
- OpenBSD
- Solaris/OpenIndiana
- Gentoo
Installation Guide for Ubuntu-Server: Server Guide
Installation Guide for Ubuntu-Client: Client Guide
This Guide proceed for an Ubuntu-Environment...
sudo apt-get install openjdk-6-jre
sudo apt-get install openjdk-6-jdk openjdk-6-source openjdk-6-doc openjdk-6-jre-headless openjdk-6-jre-lib
//for ubuntu dis. until v.10.04
sudo apt-get install git-core
//for newer ubuntu dis.
sudo apt-get install git
sudo apt-get install maven
sudo apt-get install python-jenkins python-mock python-nose python-paramiko openssh-server
For isolated environment use:
sudo adduser jenkins
sudo groupadd build
sudo adduser jenkins build
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
sudo echo "deb http://pkg.jenkins-ci.org/debian binary/" > /etc/apt/sources.list.d/jenkins.list
sudo apt-get update && sudo apt-get install jenkins
Upgrade to v1.514
You can find the war file here
cd /usr/share/jenkins/
sudo rm -rf jenkins.war
sudo wget http://mirrors.jenkins-ci.org/war/1.514/jenkins.war
sudo /etc/init.d/jenkins restart
After a successfull installation you can access the Jenkins-Server in your browser: localhost:8080
- Check enable security
- Check Jenkins's own user database under Access Control/Security Realm. And check Allow users to sign up.
- Set Authorization to Project-based Matrix Authorization Strategy.
- Add an admin-user and give him all rights.
- Add an anonymous-group and an authenticated-group and give them rights according to the screentshot.
Under Configure System you can configure your Jenkins-Server.
- Set the # of executors to 1.
- Set Jenkins URL to your servers name.
- You can keep the default values for all other entries.
Go to http://localhost:8080/computer/(master)/configure and add prio_build regular_build update_tarballs
to Labels.
Lists the files in your .ssh directory
cd ~/.ssh
ls
Creates a new ssh key, using the provided email as a label
ssh-keygen -t rsa -C "your_email@example.com"
exec ssh-agent bash
ssh-add id_rsa
Copies the contents of the id_rsa.pub file to your clipboard
cat ~/.ssh/id_rsa.pub >/dev/clipboard
otherwise use this
sudo cat id_rsa.pub
- Go to your Account Settings
- Click "SSH Keys" in the left sidebar
- Click "Add SSH key"
- Paste your key into the "Key" field
- Click "Add key"
- Confirm the action by entering your GitHub password
Attempts to ssh to github
ssh -T git@github.com
Went to Plugin Manager and check the wanted PlugIns for installation.
Is used to transfer build parameters from one job to the next. Here it is used to commit the repository to build or test.
Provides a view where all pipeline jobs and their dependencies are shown. It also gives the opportunity to trigger the hardware test jobs manually.
Generates the email content depending on the build/test results and sends the emails.
CONFIGURATION
A template for the Mailer-Plugin is provided in this repository. Copy it into /var/lib/jenkins/email-templates
. You can adapt the template to your requirements.
Provides comprehensive possibilities to filter the jobs that can be seen by the specific user.
To start one or more entries of a matrix job.
Authentication of users is delegated to a LDAP server.
Authentication of users is delegated to Github using the OAuth protocol.
More PlugIns will follow...
For more information visit the Jenkins Wiki
Install ROS following this Guide.
All configurations should be stored in a common folder in the $HOME
folder called jenkins-config
.
mkdir ~/jenkins-config
Set up the GitHub user. This user has to have read-access to all repositories to build and write access to your jenkins_config repository.
git config --global user.name "<USER_NAME>"
git config --global user.email "<EMAIL>"
Clone the jenkins_config repository into the jenkins-config
folder.
git clone git@github.com:ipa320/jenkins_config.git ~/jenkins-config/jenkins_config
Clone the jenkins_setup repository into the jenkins-config
folder.
git clone git@github.com:ipa320/jenkins_setup.git ~/jenkins-config/jenkins_setup
Add the jenkins_setup module to the $PYTHONPATH
.
sudo su -c 'echo "export PYTHONPATH=~/jenkins-config/jenkins_setup/src" > /etc/profile.d/python_path.sh'
sudo su -c 'echo "source /opt/ros/groovy/setup.sh" >> /etc/profile.d/python_path.sh'
Afterwards reboot the Jenkins-Server!
sudo /etc/init.d/jenkins restart
The Tarball-Server stores all the chroot tarball which will be used during the build process. It can be the Jenkins master or another server. In both cases you have to create a chroot_tarballs
folder in $HOME
which contains another folder where the used chroot tarballs will be stored.
mkdir -p ~/chroot_tarballs/in_use_on__<JENKINS MASTER NAME>
sudo visudo -f /etc/sudoers
and add to the file:
jenkins ALL=(ALL) NOPASSWD: ALL
ssh-copy-id <master - name> # _on slave_
ssh <master - name> # _on slave_
ssh-copy-id <slave - name> # _on master_
sudo apt-get install pbuilder devscripts
Performance Improvement
For configurations a file called ~/.pbuilderrc in the slaves $HOME
folder is needed, /etc/pbuilder/pbuilderrc
is an alternative.
Pbuilders aptcache
The aptcach of pbuilder is very useful but when the cache is getting bigger gradually it takes quite a while to open a chroot from the tarball. If you don't want to use it (for instance if you use an external apt-cacher), add the following to ~/.pbuilderrc
:
# don't use aptcache
APTCACHE=""
Use ccache for build
To use ccache inside the pbuilder add the following to ~/.pbuilderrc
:
# ccache
sudo mkdir -p /var/cache/pbuilder/ccache
sudo chmod a+w /var/cache/pbuilder/ccache
export CCACHE_DIR="/var/cache/pbuilder/ccache"
export PATH="/usr/lib/ccache:${PATH}"
EXTRAPACKAGES=ccache
BINDMOUNTS="${CCACHE_DIR}"
Use multi-core zipping
To speed up the zipping and unzipping of the chroot tarball's, install pigz.
sudo apt-get install pigz
And add the following to ~/.pbuilderrc
:
# pigz; multicore zipping
COMPRESSPROG=pigz
Mount memory to run the pbuilder chroots in it
Installations and builds inside the chroot need quite a lot write accesses. If you don't have a SSD installed, you can use the memory for this. Therefore you have to create a filesystem in your RAM, using tmpfs
by adding the following to the slaves /etc/fstab
:
# pbuilder
tmpfs /var/cache/pbuilder/build tmpfs defaults,size=32000M 0 0
The size depends on the size of the chroot you will work with (at least 3G... more is better). It can be larger then the RAM size. If the chroot size exceeds the RAM size it will use the SWAP as well.
Additionally you have to add the following to ~/pbuilderrc
:
# tmpfs
APTCACHEHARDLINK=no
Finally mount tmpfs
by entering (as root):
mount -a
For the usage of the Cob-Pipeline three parts are necessary:
This plugin allows the user to configure its individual build/test pipeline via the Jenkins web interface. Afterwards the automatic generation of the pipeline can be triggered.
This repository has to be available on the Jenkins-Server. It includes the code for the pipeline generation.
In this repository all the pipeline configurations are stored.
Download the .hpi and place it in /var/lib/jenkins/plugins
.
cd /var/lib/jenkins/plugins
sudo wget https://github.com/ipa320/cob-pipeline-plugin/raw/master/releases/v0.9.6/cob-pipeline.hpi
Restart your Jenkins-Server
sudo /etc/init.d/jenkins restart
Go to the Cob Pipeline Configuration section. The following fields are all required for the use.
- Jenkins Admin Login/Password
This is the user you configured before in the Configure Security part with all the permissions. Enter its login name and password.
- Configuration Folder
Enter the path of the Cob-Pipeline configuration folder.
/home/jenkins/jenkins-config
- Tarball Location
Enter the location where the tarballs are stored.
jenkins@localhost:/home/jenkins/chroot_tarballs
- GitHub User Login/Password
This is the user that has read-permission to all the repositories you want to be tested. It has also write-permission to your jenkins-config repository.
- Pipeline Repositories Owner/Fork
GitHub user that ownes the ^jenkins_setup^ and the ^jenkins_config^ repository.
ipa320
- ROS Releases
ROS versions that should be supported by your build/test pipeline.
groovy hydro
- Robots
Nodes which can be chosen for Hardware Build/Test jobs.
- Target Platform URL
URL where the ROS targets.yaml is stored, defining the Ubuntu target platforms for each ROS Version, e.g..
https://raw.github.com/ipa320/jenkins_setup/master/releases/targets.yaml
When you fill out the fields, the values will be validated in the background.
To set up the necessary chroot tarballs and keep them up-to-date an additional job is needed. Copy the prepared job config.xml
into the job folder and make the jenkins user own it.
sudo mkdir /var/lib/jenkins/jobs/update_chroot_tarballs
sudo cp ~/jenkins-config/jenkins_setup/templates/update_chroot_tarballs/UPDATE_CHROOT_TARBALLS_config.xml /var/lib/jenkins/jobs/update_chroot_tarballs/config.xml
sudo chown -R jenkins:jenkins /var/lib/jenkins/jobs/update_chroot_tarballs
Open /var/lib/jenkins/jobs/update_chroot_tarballs/config.xml
and adjust it to your demands:
- set the SERVERNAME to your Jenkins server
- set the APT_CACHER_ADDRESS to your apt-cacher
Afterwards Reload Configuration from Disk under [localhost:8080/manage](http://localhost:8080/manage) and run the job to create the tarballs.
To update all pipelines (e.g. after a general configuration change) an additional job is needed. Copy the prepared job
config.xml
into the job folder and make the jenkins user own it.
sudo mkdir /var/lib/jenkins/jobs/update_pipelines
sudo cp ~/jenkins-config/jenkins_setup/templates/update_pipelines/UPDATE_PIPELINES_config.xml /var/lib/jenkins/jobs/update_pipelines/config.xml
sudo chown -R jenkins:jenkins /var/lib/jenkins/jobs/update_pipelines
Afterwards Reload Configuration from Disk under localhost:8080/manage and run the job to create the tarballs. you will have to start this job manually and give it the admin user and password (if using github OAuth, the use the token from localhost:8080/me/configure when logged in as the Admin user.
Login as Admin and create a new view by pressing the +.
Name it current_user and select List View. Add Job Filter in the Job Filter section and select User Permissions for Jobs. Configure as shown in the picture and press OK.
Go to localhost:8080/configure and select current_user as Default view.
Copy the jelly template for the E-Mail generation
sudo mkdir /var/lib/jenkins/email-templates
sudo cp ~/jenkins-config/jenkins_setup/templates/email-templates/html-with-health-builds-tests.jelly /var/lib/jenkins/email-templates/
sudo chown -R jenkins:jenkins /var/lib/jenkins/email-templates
Prepare the jenkins node for graphical tests by installing VirtualGL and TurboVNC.
sudo ~/jenkins-config/jenkins_setup/scripts/graphicTest/prepareNode.bash
sudo reboot now
The graphics driver must be an version of the official nvidia driver. Successfully tested were the versions nvidia-current, nvidia-304 and nvidia-304-experimental. Other nvidia drivers are likely to work as well but are not tested yet.
sudo add-apt-repository ppa:ubuntu-x-swat/x-updates
sudo apt-get update
sudo apt-get install nvidia-current-dev
sudo reboot now
Install Apache2
sudo apt-get install apache2 apache2-doc
went to:
cd /etc/apache2/mods-enabled
sudo nano proxy.conf
and add this:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName jenkins
ServerAlias jenkins
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost on
ProxyPass / http://localhost:8080/
</VirtualHost>
than went to:
cd /etc/apache2
sudo nano apache2.conf
and add to the bottom:
ServerName localhost:8080