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.
- Jenkins Master Running
- EC2 Centos Instance -
- With Internet Access
- Security Group with Port
8080open for internet - Java v1.8.x
We will be using open java for our
yum install java-1.8* -y
#yum -y install java-1.8.0-openjdk# 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_keysCopy 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_hostsConfigure the node as shown here
Manage Jenkins > Manage Nodes > New Node
Configure new Node and add private key in jenkins credentials
- Create “new item”
- Enter an item name –
My-First-Project- Chose
Freestyleproject
- Chose
- Under
GeneralSection- Choose
Restrict where this project can be run- Update your jenkins slave label
Java
- Update your jenkins slave label
- Choose
- 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 "_______________________________"
- Save your job
- Build job
- Check "console output"