I was recently setting up a Jenkins Server, here is a simple tutorial on how to do it.
- Jenkins Build Server for building a gradle project
- Github Authentication
- Run Builds from Github private repository
- Build Pull requests
Get a Ubuntu 12.04 Server with at-least 1 GB RAM and a good processor.
If you are building this on EC2 a
M1 Small Instance will suffice.
Step 1: Setup Ubuntu
- Install openjdk on the server by typing
sudo apt-get install openjdk-7-jdkon the terminal.
sudo apt-get install git
Step 2: Install jenkins
Install jenkins by following the tutorial on jenkins-ci.org
wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -
- Add the following line to
deb http://pkg.jenkins-ci.org/debian binary/
sudo apt-get update
sudo apt-get install jenkins
Step 3: Start Jenkins
- Start the Jenkins server by typing
sudo service jenkins start,
- Make sure its running by typing
sudo service jenkins statusto get a result like
Jenkins Continuous Integration Server is running with the pid xxxx.
- And finally visit the
http://<sever-ip>:8000/to get a page like
Step 4 : Install plugins
Here is a list of plugins and version that I have installed at the time of writing this tutorial
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
These plugins can be installed from
Manage Plugins page
Step 5 : Configure Jenkins
- Open the configuration page
- Set jdk installation to
- Assuming you have installed git via the package manager, you can leave the configuration as it is.
- Assuming the gradle plugin has been installed, Configure the gradle installation
- Set the url of the jenkins server
- Configure the git installation of the git client
- Setup Email Notifications if you need it
- Setup the github hook and the pull request builder, Refer Step 8 for the credentials of the pull request builder.
The admin list is a list of admin usernames in github separated by
Step 6: Setup Security with Github Login
- To use github login, Register an application with github. Make sure the callback url is
- Once the application is registered copy the
- And add them to the oauth plugin
- Set the admin github users and organisations
Step 7: Setup ssh key for jenkins
- Ssh into the server and swtich user to
jenkinsusing the command
sudo su jenkins
- Navigate to the home directory and create a directory called
- use the command
ssh-keygen -t rsato generate a new ssh key , do not set any password for the key
- restart the jenkins server using
sudo service jenkins restart
Step 8: Builds user
- Create a new builds user in github
- Upload the public key generated in the previous step to github
- Grant permission for the builds user to access your private repository
- Enter the credentials of the build user for the pull request builder in Step 5.
- Refer help.github.com for more information on this step
Step 9: Create a new Job
Create a new job
Setup the vcs for the job as git, Enter the repository url from which to clone, like
- Set the name of the repository ass
- Specify the branch to build like
- Set the repository browser as githubweb and specify the url of the Github project like
- Check the options
Build when a change is pushed to GitHuband
Github pull requests builder
- Add a build step
Invoke a gradle script
- Add a new build post build action for sending an email.
Enjoy the power of Continuous Integration on you Github project with gradle builds.