Skip to content

ipa-fmw-ak/jenkins_setup

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

1. Prerequisites

1.1 Operating System

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...

1.2 Java Runtime 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

1.3 Git

//for ubuntu dis. until v.10.04
sudo apt-get install git-core
//for newer ubuntu dis.
sudo apt-get install git

1.4 Maven

sudo apt-get install maven

1.5 Basic Packages

sudo apt-get install python-jenkins python-mock python-nose python-paramiko openssh-server

2. Jenkins Installation

2.1 Preparing a Build Server for Jenkins

For isolated environment use:

sudo adduser jenkins
sudo groupadd build
sudo adduser jenkins build

2.2 Debian packages "Debian/Ubuntu"

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

Individual Package Download

2.3 Up and Downgrade

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

3. Jenkins Configuration

3.1 Global Security

  • 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.

3.2 Manage Jenkins

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.

3.3 Master Node Configuration

Go to http://localhost:8080/computer/(master)/configure and add prio_build regular_build update_tarballs to Labels.

3.4 Generating SSH-Key for GitHub

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

4. Jenkins-PlugIns Installation

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

5. IPA Configuration

5.1 Robotic Operating System

Install ROS following this Guide.

5.2 Master

5.2.1 Create Cob-Pipeline Configuration Folder

All configurations should be stored in a common folder in the $HOME folder called jenkins-config.

mkdir ~/jenkins-config

5.2.2 Git Configuration

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>"

5.2.3 jenkins_config Repository

Clone the jenkins_config repository into the jenkins-config folder.

git clone git@github.com:ipa320/jenkins_config.git ~/jenkins-config/jenkins_config

5.2.4 jenkins_setup Repository

Clone the jenkins_setup repository into the jenkins-config folder.

git clone git@github.com:ipa320/jenkins_setup.git ~/jenkins-config/jenkins_setup

5.2.5 PYTHONPATH

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

5.2.6 Tarball Server

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>

5.3 Slave

5.3.1 Sudo Rights

sudo visudo -f /etc/sudoers

and add to the file:

jenkins    ALL=(ALL) NOPASSWD: ALL

5.3.2 SSH Access

ssh-copy-id <master - name>    # _on slave_
ssh <master - name>            # _on slave_
ssh-copy-id <slave - name>     # _on master_

5.3.3 Pbuilder

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

5.4 The Cob-Pipeline

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.

5.4.1 Install the Cob-Pipeline

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

5.4.2 Configure the Cob-Pipeline

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.

5.4.3 Configure update_chroot_tarballs job

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.

5.4.4 Configure update_pipelines job

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.

5.4.5 Configure default view

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.

5.4.6 Configure mailer

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

5.4.7 Configure the JenkinsServer for graphics tests

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

5.6 Set Jenkins to Port 80

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

About

Jenkins Setup

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 91.8%
  • Shell 8.2%