Install Jenkins Ubuntu

Posted on Sunday, January 26, 2014


This guide will go over installing and setting up Jenkins on a fresh Ubuntu 12.04 server.


In this installation I am going to follow the guide given at https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu [1]


Installing Java 7


Install the latest java 7 files


>  sudo apt-get purge openjdk*
>  sudo apt-get install python-software-properties
sudo add-apt-repository ppa:webupd8team/java
>  sudo apt-get update
>  sudo apt-get install oracle-java7-installer
>  java -version




Installing Jenkins


Run the following commands to install Jenkins (as taken from https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu [1])



>  wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
> sudo sh -c '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





Open up the Jenkins web page (it listens on port 80)
My server happens to be running locally on 192.168.0.7




It works


Check to make sure the jenkins home directory is correct.
Click on Manage Jenkins




Then configure system





Make note of the Jenkins home directory (You may need to know it at some point)
/var/lib/jenkins



Set up Jenkins security


Now that Jenkins is set up we need to set up its security to prevent unwanted users from logging in and running builds.  Out of the box anyone can get into Jenkins which is a bit of a security risk.

From the main Jenkins screen click on “Manage Jenkins”




Then click on Configure Global Security




Checkbox Enable Security





We are going to use our unix users /groups.  
Checkbox “Unix user/group database”  then click test to test the connection.  If it returns success you are good.




After clicking Test you should see this error




Jenkins needs to be added to the shadow group.  Run the following command to do this.



>  sudo usermod -a -G shadow jenkins


Restart jenkins


>  sudo /etc/init.d/jenkins restart


Go back and set the Security Realm to Unix user.group and click Test again



Now we see success

Select the Matrix-based Security and add each user individually (in our case patman and shartley)





Add users or groups by hand






Then give them every permission (but make sure anonymous has no permissions).




Click Save at the bottom.




Now if you go to jenkins you will get a login prompt.








Put in your username/password  and login






That is it for a basic Jenkins install I have not set up any builds yet in it or set up Ant.


I will cover those in other articles.


References
[1]        Jenkins install guide (Ubuntu)
                Accessed 01/2014



No comments:

Post a Comment