It's very easy to set up Jenkins server and build a project with it.

The feature of this setup is that Openshift creates new slave machine (standrad Openshift app) once job is started and destroy it after a while.

 

The main disadvantage is that if you have defined more than one jobs then jenkins will have access only to the latest build's workspace.

 

Here is how to set up standard slave node on Openshift and configure Jenkins to use it.

 

1. Create Jenkins server

How to do that is here: https://openshift.redhat.com/community/jenkins

 

2. Create new DYI app as a slave node

How to is here: https://openshift.redhat.com/community/videos/getting-started-with-diy-applications-on-openshift

 

3. Create SSH keys on jenkins server

Jenkins server needs to access your slave via SSH so you need to create new ssh keys.

Good place where to keep them is ~/app-root/data/ within your build server.

 

So login to your jenkins server and do:

 

cd  ~/app-root/data/
mkdir ssh
cd ssh

# enter location ./id_rsa instead of default location at ~/.ssh/
ssh-keygen

 

Now you have private and public key which can be used to access slave.

 

Slave is standard Openshift appplication so it trusts connections made via ssh key defined in your openshift account. So go to your Openshift account and add your new created ssh public key to the list of ssh keys.

 

Now you can connect from build server to slave via ssh for example:

 

ssh -i ~/app-root/data/id_rsa <path to your slave node>

 

4. Create Jenkins Node

Go to Jenkins web UI and navigate to Manage Jenkins > Manage Nodes

 

Create new node and put these values:

 

Remote FS root: absolsute path to your /app-root/data on slave

Labels: use any label that will be used in your job configurations

Host: slave host

Host Advanced option:

  username: userid of slave node

  Private Key File: path to your generated private SSH key on jenkins server

 

5. Create a job

Create standard Jenkins job and don't forget to use same label as you used in node definition. Correct label is important because Openshift by default use same label as job name is which triggers creating new slave node instead using your node.

 

That's it!

 

Now you can define more jobs to use same slave (same label). Now you have in Jenkins access to workspaces of all your jobs and you have full control of your node.