Skip to content

chaitratk/Jenkins-master-slave

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 

Repository files navigation

Configure Jenkins Slaves on AWS EC2

Jenkins is a self-contained Java-based program, ready to run out-of-the-box, with packages for Windows, Mac OS X and other Unix-like operating systems. As an extensible automation server, Jenkins can be used as a simple CI server or turned into the continuous delivery hub for any project.

Prerequisites

  1. Jenkins Master Running
  2. EC2 Centos Instance -
    • With Internet Access
    • Security Group with Port 8080 open for internet
    • Java v1.8.x

Install Java

We will be using open java for our

yum install java-1.8* -y
#yum -y install java-1.8.0-openjdk

Setup Jenkins Slave

# Create user and add the user to wheel group
useradd jenkins-slave-01
# Create SSH Keys
sudo su - jenkins-slave-01
ssh-keygen -t rsa -N "" -f /home/jenkins-slave-01/.ssh/id_rsa
# The private and public keys will be created at these locations `/home/jenkins-slave-01/.ssh/id_rsa` and `/home/jenkins-slave-01/.ssh/id_rsa.pub`
cd .ssh
cat id_rsa.pub > authorized_keys
chmod 700 authorized_keys

Configuration on Master

Copy the slave node's public key[id_rsa.pub] to Master Node's known_hosts file

mkdir -p /var/lib/jenkins/.ssh
cd /var/lib/jenkins/.ssh
ssh-keyscan -H SLAVE-NODE-IP-OR-HOSTNAME >>/var/lib/jenkins/.ssh/known_hosts
# ssh-keyscan -H 172.31.38.42 >>/var/lib/jenkins/.ssh/known_hosts
chown jenkins:jenkins known_hosts
chmod 700 known_hosts

Configure the Slave using Manage Jenkins

Configure the node as shown here Manage Jenkins > Manage Nodes > New Node Configure new Node and add private key in jenkins credentials

Test Jenkins Jobs

  1. Create “new item”
  2. Enter an item name – My-First-Project
    • Chose Freestyle project
  3. Under General Section
    • Choose Restrict where this project can be run
      • Update your jenkins slave label Java
  4. Under Build section Execute shell
    #!/bin/bash
    echo "_______________________________"
    echo "|                             |"
    echo "|Welcome to Tejas tech Demo   |"
    echo "|           _nnnn_            |"
    echo "|          dGGGGMMb           |"
    echo "|         @p~qp~~qMb          |"
    echo "|         M|@||@) M|          |"
    echo "|         @,----.JM|          |"
    echo "|        JS^\__/  qKL         |"
    echo "|       dZP        qKRb       |"
    echo "|      dZP          qKKb      |"
    echo "|     fZP            SMMb     |"
    echo "|     HZM            MMMM     |"
    echo "|     FqM            MMMM     |"
    echo "|   __| '.        |\dS'qML    |"
    echo "|   |    '.       | ' \Zq     |"
    echo "|  _)      \.___.,|     .'    |"
    echo "|  \____   )MMMMMP|   .'      |"
    echo "|       '-'       '--' hjm    |"
    echo "_______________________________"
  5. Save your job
  6. Build job
  7. Check "console output"

About

Jenkins Master slave configuration

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published