NH

Install and setup jenkins for production

Cover Image for Install and setup jenkins for production
Nasrul Hasan
Nasrul Hasan

Jenkins Installation

There are many ways in which we can configure jenkins but for this blog we will use ec2 instance to install jenkins and from there we will create a ci/cd pipeline to deploy our application.

1. Spin up a ubuntu EC2 instance (you can also use any linux server on Virtual Machine or bare metal )

For Ubuntu use below commands to install

 curl -fsSL https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key | sudo tee \
  /usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] \
  https://pkg.jenkins.io/debian-stable binary/ | sudo tee \
  /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt install openjdk-17-jre
sudo apt-get install jenkins

For Redhat use below commands to install

 sudo wget -O /etc/yum.repos.d/jenkins.repo \
    https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
sudo yum upgrade
# Add required dependencies for the jenkins package
sudo yum install java-17-openjdk
sudo yum install jenkins
sudo systemctl daemon-reload

2. Now enable and start jenkins service on you machine

 sudo systemctl enable jenkins
sudo systemctl start jenkins

3. Add Jenkins to the docker group by below command. if docker not installed see this blog geting-started-with-docker

  sudo usermod -aG docker jenkins

4. Open browser and enter localhost:8080.

Alternatively you can go to http://<your-machine-ip>:8080. In case of ec2 instance go to http://<public-ip-of-ec2>:8080

Note: Don't forget to open port 8080 from security group.

5. Now it will ask for first time admin password. You can find this on your linux machine under /var/jenkins_home/secrets/initialAdminPassword.

 cat /var/jenkins_home/secrets/initialAdminPassword

6. Now copy this and paste it in your browser'

7. Setup your admin login creds and click on install suggetsted plugins.

With this Jenkins is successfully installed on your linux server. Now we will use this to automate deployments.

To learn how to create CI CD pipeline checkout my blog --> CI CD the Jenkins way (comin soon...)

#Jenkins#CI/CD#Deployment#Devops tools