Menu
  • Home
  • About Me
  • Blog
  • Github
  • LinkedIn

Create Orchestration Tool (Jenkins) With Azure Cloud Infrastructure

January 21, 2022March 17, 2023

I’m going to create a Jenkins to enable CI/CD Pipelines.

Create a VM

Create a Linux VM with the following specifications.

Add an inbound security rule that allows access to your Jenkins VM on TCP port 8080.

Install Docker and Jenkins

sudo apt-get -y update && sudo apt-get upgrade -y

Download and add Docker CE GPG key with the following command:

wget https://download.docker.com/linux/ubuntu/gpg
apt-key add gpg

Next, add the Docker CE repository to APT with the following command:

nano /etc/apt/sources.list.d/docker.list


deb [arch=amd64] https://download.docker.com/linux/ubuntu xenial stable
sudo nano /etc/apt/sources.list.d/docker.list

Save and close the file, then update the repository.

sudo apt-get update -y
sudo apt-get install docker-ce -y

sudo systemctl status docker

Create Docker Volume for Data and Log

docker volume create jenkins-data
docker volume create jenkins-log

docker volume ls

Install Jenkins with Docker

mkdir docker
nano docker/dockerfile

Add the following lines:

FROM jenkins/jenkins
LABEL maintainer="hitjethva@gmail.com"
USER root
RUN mkdir /var/log/jenkins
RUN mkdir /var/cache/jenkins
RUN chown -R jenkins:jenkins /var/log/jenkins
RUN chown -R jenkins:jenkins /var/cache/jenkins
USER jenkins
 
ENV JAVA_OPTS="-Xmx4096m"

ENV JENKINS_OPTS="--handlerCountMax=300 --logfile=/var/log/jenkins/jenkins.log
--webroot=/var/cache/jenkins/war"

Note: When setting up the dockerfile for your Jenkins image, set the Java memory below 8192

cd docker
docker build -t myjenkins .

Run Jenkins Container with Data and Log Volume

docker run -p 8080:8080 -p 50000:50000 --name=jenkins-master --mount source=jenkins-log,target=/var/log/jenkins --mount source=jenkins-data,target=/var/jenkins_home -d myjenkins

Don’t forget to add inbound rule TCP port 8080.

docker exec jenkins-master tail -f /var/log/jenkins/jenkins.log

# If you need more lines, add -n option

docker exec jenkins-master tail -n 20 -f /var/log/jenkins/jenkins.log

you should see the password to proceed to installation:

b437ba21655a44cda66a75b8fbddf5b8
 
This may also be found at: /var/jenkins_home/secrets/initialAdminPassword
 
*************************************************************
*************************************************************
*************************************************************

Provide your administrator password and click on the Continue button. You should see the following page:

Now, click on the “Install suggested plugins” to install the required plugins. Once the installation has been finished. You should see the following page

Now, provide your admin username, password and full name then click on the Save and Finish button. You should see the following page:

Now, just click on the Save and Finish button. Once the setup completed successfully, you should see the following page:

Troubleshooting

dial unix /var/run/docker.sock: connect: permission denied

If you get permission denied while trying to connect to the Docker daemon, you need to create the docker group and add your user.

To create the docker group and add your user:

sudo groupadd docker
sudo usermod -aG docker ${USER}
newgrp docker

docker run hello-world

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Recent Posts
  • ChinguTalkBot v0.1.0: Setting up AWS Cognito with CDK for User Authentication
  • Phoenix & Elixir: Fix PostgreSQL connection refused
  • Demo: Git Log with Shell script to create a release notes
  • Metasploit
  • CyberSecurity Lab – Online Password Attack

Archives
  • March 2024
  • May 2023
  • April 2023
  • February 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022
  • August 2022
  • July 2022
  • June 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
Categories
  • Amazon Interview (3)
  • Ansible (3)
  • AWS (9)
  • Azure (9)
  • Certification (2)
  • ChinguTalkBot Project (1)
  • cybersecurity (3)
  • Data analytics (6)
  • Demo Videos (6)
  • Docker (5)
  • Git (1)
  • GitLab (1)
  • Golang (3)
  • JavaScript (2)
  • Jenkins (4)
  • PowerShell (1)
  • Python (10)
  • Terraform (11)
  • Uncategorized (9)

©2025 | Powered by WordPress and Superb Themes!