Archive

Archive for February, 2015

Jenkins and Bitbucket [Maven Project as Example]

February 22, 2015 Leave a comment

In this post, i’ll explain short brief how to integrate between bitbucket and jenkins as a part of continues integration cycle.

before reading this, assumed :

1. Jenkins has been installed on server

2. Bitbucket account and project has been created and configured properly.

what we have todo are :

Preparation :

Jenkins Part :

1. Install bitbucket plugins

2. Install Git Plugins 

3. generate ssh keys using ssh-keygen command as jenkins user. On linux machine you could do this :

a. su – jenkins

b. ssh-keygen

Screen Shot 2015-02-22 at 1.23.37 PM

4. Copy id_rsa.pub content,  generated on step 4 (this key will be used on bitbucket part, adding ssh keys section)

 

Bitbucket Part:

1. Setup a project, ie. named jenkin-testing

2. Add ssh keys to current project.

a. open setting

b. add ssh keys

c. give title, and paste ssh keys, generated on step 4 at jenkins part section above

3. Add hook to jenkins server , using POST hook

1. Open Hooks on setting section

2. select POST, then click Add HOOK

3. Insert url : jenkins_server:port/bitbucket-hook/

4. Save and close

 

Configuration :

Jenkins Part :

When Bitbucket setup is finished, try to clone project from bitbucket using jekins as user:

su – jenkins

git clone git@bitbutcket.com/jenkin-testing.git

if succeed, then move to section below ..

1. Setup new Item, select maven project, add project title

Screen Shot 2015-02-22 at 1.14.20 PM

2. select Git on source code management

a. insert git url [similar to git clone]

Screen Shot 2015-02-22 at 1.16.39 PM

b. add credential [jenkins username and password ]

Screen Shot 2015-02-22 at 1.18.27 PM

 

3. Defined branch to build [default master]

4. Then select Build when a change is pushed to BitBucket

Screen Shot 2015-02-22 at 1.19.32 PM

5. Select Run Onlyif Build Succeeds

Screen Shot 2015-02-22 at 1.21.33 PM

6. Then click Apply and Save

 

Now Jenkins and Bitbucket integration already to launch ..

Let’s take a test :

1. Clone jenkin-testing project

2. Make same Changes

3. The commit and Push changes to bitbucket

 

Then see what happened on Jenkins server, The Project Build Job will run immediately as changes Pushed to bit bucket ..

 

For Next Post, will explain how to integrate Jenkins Maven and Glassfish server integration ..

 

Jakarta, 22 February 2015

 

A. Ahmad Kusumah

 

Advertisements