How to install Jenkins for continous integration and deployment using bitbucket

[Mobile version(QRCode)] Total views:50,068 / Applauds for blog:1
Welcome to my page. I am an adminisrator of this site.
If you are this db's user, please contact with me by private mail. If not, please contact with me by email or twitter or facebook
Access record[Graph / PV Info.(Past 1 day / Past 1 week) / Access from outside (Yesterday / Past 1 week) / Vistors's list]
ProfilePmail(Mail)
Inbox   /Send   /Sent
Reviews(List   /Limit)
Poll   /Agree:Got   /Sent
Fan
Works/Music
Blog
[Write]
Links
My Play List
<=Newer article2016/02/12 How to set up Auto scale in AWS
=>Older article2016/01/25 How to construct CI environment

1.
2016/02/11 "Jenkins > How to install Jenkins for continous integration and deployment using bitbucket"
[Show only this article / Modify / Delete / Send trackback / Add to the shared category]

1. Why do you use Jenkins for Continuous integration and delivery?
2. Install Jenkins
3. Set up initial security for Jenkins
4. Manage plug-in
5. Set up for integration with Bitbucket
6. Create job which will be triggered by push to bitbucket

1. Why do you use Jenkins for Continuous integration and delivery?

Cloud service is easy but they have the limitation of programming language and they will cost some price.
If you are not happy to use cloud service, then let's install Jenkins by yourself.
Down side is the cost of your operation and upper side is the flexibility of the environment.
2. Install Jenkins

The procedure is quite easy.

In the case of Ubuntu:
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu

Install
wget -q -O - https://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
sudo apt-get install git

Upgrade
sudo apt-get update
sudo apt-get install jenkins

In the case of Redhat (CentOS):
https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Red+Hat+distributions

sudo wget -O /etc/yum.repos.d/jenkins.repo http://pkg.jenkins-ci.org/redhat/jenkins.repo
sudo rpm --import https://jenkins-ci.org/redhat/jenkins-ci.org.key
sudo yum install jenkins
sudo yum install java

sudo chkconfig jenkins on
sudo /etc/init.d/jenkins start

Now you can access to Jekins through the port 8080.

http://SERVER-NAME:8080/
3. Set up initial security for Jenkins

Manage Jenkins => Setting of Global security

Check check box of enabling security
Check radio button of user database of Jenkins
Check check box of allowing users to sign up

Go to screen for logging in and sign up

Manage Jenkins => Setting of Global security

Disable sign up function.

Check radio button of administration by line-column

Add user accounts and check check box of privileges. If the account is the first one, you should give all privileges.

Log out and log in again to confirm that the system is working correctly.
4. Manage plug-in

Manage Jenkins => Manage plug-in

Install Bitbucket plugin with restarting

Update installed plugin.

Restart Jenkins
5. Set up for integration with Bitbucket

sudo su - jekins
ssh-keygen

If you cannot log in as jenkins, check /etc/passwd and /bin/bash is specified as a shell.
If not, modify the part.

Register /var/lib/jenkins/.ssh/id_rsa in the ssh setting of bitbucket

As jenkins user

vi ~/.ssh/config
Host bitbucket.org
port 22
Hostname bitbucket.org
IdentityFile ~/.ssh/id_rsa
TCPKeepAlive yes
IdentitiesOnly yes
chmod 600 ~/.ssh/config

Confirm the setting
ssh -T git@bitbucket.org

Go to the project page of bitbucket
Setting => Webhook => Add webhook

Set the url
http://JENKINS-SERVER:8080/git/notifyCommit?url=git@bitbucket.org:USER-NAME/REPO-NAME.git
6. Create job which will be triggered by push to bitbucket

Create new job

- Choose git
Set git@bitbucket.org:user_name/REPO-NAME.git in Repository URL

- Choose bitbucketweb in repository browser
Set https://USER-NAME@bitbucket.org/USER-NAME/REPO-NAME.git in URL

- Check Polling SCM in Build trigger

- Build => Add the procedure of build -> Execute Shell => Write some shell script

Then commit and push to bitbucket.
The job will be triggered by push.

Git files will be cloned under
/var/lib/jenkins/workspace/$PJNAME

So you can do anything from here.
You can define the procedure of continuous integration or delivery from here.

Add comment to this article


[Read other articles]
<=Newer article2016/02/12 How to set up Auto scale in AWS
=>Older article2016/01/25 How to construct CI environment


Articles categorized as "Jenkins by this user"
All articles of this user
Subscribe to RSS
RSS
Display Style of blog
List/Mobile(QRCode)
Term
Category
All
1.Japan
2.Atlassian's products
3.Self
4.Development of this site
5.Japanese comics
6.Japanese anime
7.Weekly hot news of Japanese culture
8.OP/ED/PV
9.Japanese game
10.Ranking
11.Japanese Comics (Manga)
12.Search Engine
13.Japanese drama
14.Japanese otaku culture
15.Programming
16.Ineternet world
17.Movie
18.C/C++
19.BerkeleyDB
20.Apache programming
21.Spam
22.Meteor
23.Marketing
24.Python
25.Scrum
26.JIRA
27.Git
28.CI
29.Jenkins
30.AWS
31.Operation
32.Singapore
33.Cloud
34.Mysql Cluster
35.DevOps
36.Bitbucket
37.Xamarin
38.Good and new
39.Monitoring
40.node.js
Sayings from S-Cry-Ed

Rule in this world is speed. Even stupid person can write cool novel if he can spend 20 years for it.

If someone helped me, I will help him in return, which is my rule.

To become stronger, consider what is cowardliest thinking. And rebel against the thinking, which will make you stronger.



I am Japanese but working for some English sites.

Doctor Job Career
Nurse Job Career
Top Page top MetaSeachJP Works