Skip to main content

Installing Jenkins on RedHat on AWS EC2

1) Create an EC2 Instance from the aws amazon.com UI with basic free tier configuration and select RedHat AMI
2) Generate KeyPair if its not already generated
3) Store the key-pair in secure location in your system and change its permission to 400 which means only the owner can utilize it 
4) I'm using windows wsl , so it did not let me modify the permission in the download directory so I copied the file in linux direcotry ( /home/<username>/) and then changed its permission using chmod
sudo chmod 400 myec2login.pem
5) Then I logged in to my ec2 instance using ec2-user which is default user for ec2 instances providing the path of this file 

ssh -i "/path/to/ec2pemFile" ec2-user@ec2IPaddress

6) First installed the java version 8 on the instance as Jenkins needs java 8 run time 
sudo yum install java-1.8.0-openjdk-devel.x86_64
In case there was already a different version of java available,
 you have to run alternative config command on linux to select this version to reflect in java --version
command is sudo update-alternatives --config java 
this will list all java options and will ask you to enter the number for the option for which you want to point

7) Then follow instructions on jenkins guide for redhat 
https://www.jenkins.io/doc/book/installing/#red-hat-centos

1) Download the jenkins redhat package 
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
2) Import the rpm key from jenkins stable release 
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
3) Upgrade yum to keep any required latest data
sudo yum upgrade

4) Install jenkins 
sudo yum install jenkins
IN case wget is not found you can install using sudo yum install wget

8) Now start the jenkins service 

sudo service jenkins start

9) By default Jenkins start on port 8080, you can access it UI by entering the publicIP:8080 . Example 

Jenkins First launch screen

In case you are not able to access the port, make sure the port is accessible for http access. 
IN case you are using ec2 instance, you have to add a security group and allow inbound cusotm tcp access either from a public IP of your machine/subnet  or give access to all the IP address on port 8080


In case you are facing issues with fetching git urls in jenkins job, make sure git is installed on jenkin server otherwise install with  sudo yum install git

Once the security group is created, apply that to the Jenkins instance
After that you should be able to access the jenkins UI 

10) Enter the password from the file mentioned in the UI to get the secure one time password ( use it with sudo to cat the file ) 
Make sure, you dont copy spaces at the end 

11) you can install the suggested plugin or you can choose 



12) Then add the login details which you would be repeatedly using 

13) then the home page will appear where you can start using the Jenkins to create different jobs

Comments

Popular posts from this blog

Install Docker on EC2

1) Launch EC2 instance , the one with docker support on it  2) Then follow simple below 4 instructions   Update yum for any package  The install docker  then start the docker service  register the ec2-user in docker sudo group to execute commands without sudo permission  a) sudo yum update -y  b)  sudo yum install -y docker c)  sudo service docker start d)  sudo usermod -a -G docker ec2-user you can verify the  docker installation by running some sample docker commands like  docker image ls  docker ps  reboot the system to take an effect of sudo group

Quick Sample Docker Java Application Demo

A quick demo for Java Application container In this page, I'll show you a demo to quickly build an image and run a docker container.  To run this you must have a docker installed .  I'm going to use this on Ubuntu/Linux On windows subsystem.  1) You can create a directory for this demo using linux command    mkdir docker-demo-java 2) Change directory to new folder using cd command as cd docker-demo-java 3) create a sample java file DemoJavaContainer.java and print a sample message as "A sample docker java application demo" class DemoJavaContainer{ public static void main(String ar[]) { System.out.println("A sample docker java application demo"); } } 4) Then write a sample docker file named Dockerfile and write the below content from java:8 COPY . /var/java WORKDIR /var/java RUN javac DemoJavaContainer.java CMD ["java","DemoJavaContainer"] 5) save the file in the project directory 6) run command : docker build -t sample-docker-java-...