Jenkins - simple master, slave setup and project

Posted on Sun 25 September 2016 by Pavlo Khmel

What we'll do:

  • Install Slave
  • Install Master
  • Adding new slave node on jenkins master
  • Create new project:
    • get files from GitHub
    • archive one file
    • make it available from jenkins web page

Install slave host:

OS: CentOS 7

Install packages:

systemctl disable firewalld
systemctl stop firewalld
yum -y install java git
useradd jenkins
passwd jenkins

Master setup:

OS: CentOS 7

Jenkins 2.7.4 (current LTS)

systemctl disable firewalld
systemctl stop firewalld
curl -o /etc/yum.repos.d/jenkins.repo
rpm --import
yum -y install java jenkins
service jenkins start

Get initial Administrator password (Wait if file still does not exist. It will be created after "service jenkins start"):

cat /var/lib/jenkins/secrets/initialAdminPassword
  • Use initial Administrator password on http://[master-IP]:8080/
  • Choose: Install suggested plugins
  • Create First Admin User
  • Save and Finish

Adding new slave node on jenkins master

On http://[master-IP]:8080/

  • Manage Jenkins > Manage Nodes > New node:
  • Node name: slave
  • Select: Permanent Agent
  • OK
  • Remote root directory: /home/jenkins
  • Launch method: Launch slave agents on Unix machines via SSH
  • Host: [slave-IP]
  • Credentials: Add > Jenkins
  • Username: jenkins
  • Password: *******
  • Add
  • Save
  • Slave > Relaunch agent

Ignore rotation icon.

Ignore message or relaunch agent one more time:

[09/24/16 23:53:37] Launch failed - cleaning up connection
[09/24/16 23:53:37] [SSH] Connection closed.

Create new Jenkin's project

Go to main page on http://[master-IP]:8080/

Create new job:

  • Enter an item name: HelloWorld
  • Freestyle project.
  • OK
  • In Restrict where this project can be run > Lable Expression: slave
  • Source Code Management: Git
  • Repositories > Repository URL:
  • Build > Add build step > Execute shell
  • Command:
tar -czf
  • Post-build Actions > Add post-build Actions > Archive the artifacts
  • Files to archive:
  • Save
  • Build Now

When job is finished you can download build artifact.

In Build History click on the last build and download from jenkins page.