[ ubuntu ] Jenkin

Installation

wget -q -O - http://pkg.jenkins-ci.org/debian/jenkins-ci.org.key | sudo apt-key add -

add the following entry in your /etc/apt/sources.list

deb http://pkg.jenkins-ci.org/debian binary/
sudo apt-get update
sudo apt-get install jenkins

older version of jenkins
http://stackoverflow.com/questions/25123136/how-to-install-older-version-of-jenkins

apt-get install jenkins=1.532-1.1

or get deb from http://pkg.jenkins-ci.org/debian-stable/

Path

  • Deamon is at /etc/init.d/jenkins
  • ‘jenkins’ user is created to run this service
  • log file is at /var/log/jenkins/jenkins.log
  • configuration parameters for the launch e.g JENKINS_HOME is at /etc/default/jenkins

By default, Jenkins listen on port 8080. However, this can be changed.

/etc/default/jenkins

HTTP_PORT=8081

 

File Parameter

jenkins_files_parameter

Need “File location”, that is the file name that will be placed when upload.

Otherwise, we will get “The parameter is incorrect. FATAL: command execution failed”

 

Create new shell script job

New Job > Build a free-style software project

Build > Execute shell

 

Shell executable on windows Setup

Go to Manage Jenkins > Configure System

Shell executable : C:\Program Files\Git\bin\sh.exe

 

May need full path when execute windows program

PYTHON_BIN_PATH=”/C/Python27/python.exe”

 

Otherwise, need Setting  Jenkins path on windows

Manage Jenkins > Configure System

jenkins_path

ref : http://stackoverflow.com/questions/36473479/how-to-set-the-path-environment-variable-in-jenkins-configuration-on-windows

 

Execute Git Command on Shell

Example : git pull, git checkout

 

Build

Build > Build Now

NOTE : this will call http://YOURHOST:8080/job/PROJECTNAME/build

 

Console output

Build history > console output

Ubuntu.png

NOTE : built success : build history bullet is blue

built failure : build history bullet is red

 

Multiple steps can be added

multiple_steps.png

 

Activate ant script

Where is Jenkins Workspaces ?

Manage Jenkins > Configure System > click `Advance` button

Home directory : /var/lib/jenkins

Workspace Root Directory : ${ITEM_ROOTDIR}/workspace

Build Record Root Directory : ${ITEM_ROOTDIR}/builds

The workspace path can be founded from the console error when we try to run the task

My workspace is `/var/lib/jenkins/jobs/[job name]/workspace/`

${WORKSPACE} variable path

/var/lib/jenkins/workspace/projectname

 

Setup Slave 

setup node

NOTE : no need to install Jenkins on the slave machine

  1. Manage Jenkins > Manage Nodes

New node

suggestion : slave name should contains no space

ubuntu.png

2. Manage Jenkins > Manage Nodes

click at the jenkins slave

launch_slave

run the command on the client

java -jar slave.jar -jnlpUrl http://192.168.110.21:8080/computer/Jenkins%20slave/slave-agent.jnlp

run_slave

Restrict where this project can be run

bash -c cd “/var/lib/jenkins-slave” && java -jar slave.jar

label_expression

ref : https://wiki.jenkins-ci.org/display/JENKINS/Step+by+step+guide+to+set+up+master+and+slave+machines

 

SVM

Example

svm

 

Update Jenkins

I just purge and install from deb file from http://pkg.jenkins-ci.org/debian-stable/

NOTE : need to purge both jenkins and jenkins-common

Download jenkins.war from

http://updates.jenkins-ci.org/download/war/1.652/jenkins.war

or

http://updates.jenkins-ci.org/download/war/1.532/jenkins.war

Run

java -jar jenkins.war

ref : https://wiki.jenkins-ci.org/display/JENKINS/Automated+Upgrade

If we would like to run as a deamon, replace file at

/usr/share/jenkins/jenkins.war

ref : https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+as+a+Unix+daemon

, https://wiki.jenkins-ci.org/display/JENKINS/Installing+Jenkins+on+Ubuntu

, https://wiki.jenkins-ci.org/display/JENKINS/Building+a+software+project

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s