Friday 23 August 2019

Setting up a Jenkins Server on AWS EC2 instance


Let us first understand what is Jenkins? Jenkins is a self-contained, open source automation server which can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software. Jenkins is a software that allows continuous integration.

Prerequisites:

Launch and SSH into EC2 Instance.
Don't forget to add Port 8080 in the Security Group to open for all incoming connections.
Java JDK should be installed.

Install Java 1.8 JDK

  • sudo su
  • yum update –y
  • yum install java-1.8*

Update Bash_profile to set JAVA_HOME variable


  • To get the path of java binary - find /usr/lib/jvm/ -name java
  • Add below lines to your .bash_profile file in user's home directory. 
    • JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.191.b12-1.el7_6.x86_64
    • export JAVA_HOME
    • PATH=$PATH:$JAVA_HOME
  • save the file :wq 
  • To make the changes effective immediately update your .bash_profile
    • source ~/.bash_profile
  • java -version (check the java version)

Install Jenkins


yum -y install wget
wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo

Import a key file from Jenkins-CI to enable installation from the package

rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
yum install jenkins -y


Start Jenkins as a service


## Start jenkins service
systemctl start jenkins

## Setup Jenkins to start at boot,
systemctl enable jenkins


Accessing Jenkins UI


Visit the following address in your browser, http://EC2-SERVER-PUBLIC-IP:8080


Things to do after first login:


  • Default Password Location: cat /var/lib/jenkins/secrets/initialAdminPassword

  • Change admin password
    • Admin > Configure > Password

  • Configure java path
    • Manage Jenkins > Global Tool Configuration > JDK

  • Now you are ready to create a job for your build. Test Jenkins Job
    • Create “new item”
    • Enter an item name – My-first-job
    • Chose Freestyle project
    • Under Build section - choose option - Execute shell : echo "Welcome to Jenkins Demo"
    • Save your job
    • Build job
    • Check "console output" for successful completion of job.
Hurray!! you have just created and ran your first job.

Restarting Jenkins through browser (Only if you are logged in as Admin user)
http://<ip-address>:8080/restart

2 comments:

  1. The information which you have provided in this blog is really useful to everyone. Thanks for sharing. This post is much helpful for us. This is really very massive value to all the readers and it will be the only reason for the post
    DevOps Training in Chennai

    DevOps Online Training in Chennai

    DevOps Training in Bangalore

    DevOps Training in Hyderabad

    DevOps Training in Coimbatore

    DevOps Training

    DevOps Online Training

    ReplyDelete