Jenkins‎ > ‎

Jenkins CI polling on Gitlab server

With Jenkins server  ( ) running on an Ubuntu LTS 12.04, and attempts poll on a Gitlab ( ) server, you will find that Jenkins is not allowed to poll or clone from the Gitlab server.

There are 2 issues, The git version on Ubuntu is below Gitlab's requirements, and the Jenkins service user does not have an ssh key. Here comes a recipe for fixing.

To fix:

ssh user_with_sudo_rights@jenkins_server

This Ubuntu LTS version uses git version 1.7.x but gitlabhq expects version 1.8.x.
To upgrade git version on jenkins server - well on ubuntu LTS 12.04...

sudo apt-get upgrade
sudo apt-get install python-software-properties

sudo add-apt-repository ppa:git-core/ppa
sudo apt-get update

Then we need to create a ssh key for the service user Jenkins user. We do not know the password, which was generated by the install. The following command allow us to be user jenkins, without knowing the password:

sudo su - jenkins

As user jenkins:

cd ~
# Configure git constants
git config --global "Jenkins Service"
git config --global "jenkins_service@your_mail_domain"

# Create a key for jenkins

# show the key, copy it to your Gitlab server for the user created for polling
cat ~/.ssh/ 

# Have gitlab hosts key added to known hosts - and test that jenkins now can clone from Gitlab

mkdir tt
cd tt/
git clone git@gitlab_server:repository.git
cd ..
-Rf tt