(sudo date -s "2023-06-12 03:28:00")
sudo su -
Ensure that your software packages are up to date on your instance by using the following command to perform a quick software update:
yum update –y
wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
yum upgrade -y
amazon-linux-extras install java-openjdk11 -y
yum install maven -y
wget http://mirror.olnevhost.net/pub/apache/maven/maven-3/3.2.5/binaries/apache-maven-3.2.5-bin.tar.gz
tar xzf apache-maven-3.2.5-bin.tar.gz
sudo mv apache-maven-3.2.5 /opt/
export PATH=/opt/apache-maven-3.2.5/bin:$PATH
source ~/.bashrc
yum install -y docker
systemctl start docker
systemctl enable docker
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
yum install git -y
yum install jenkins -y
systemctl enable jenkins
sudo usermod -aG docker jenkins
sudo chown jenkins:docker /var/run/docker.sock
sudo chmod 660 /var/run/docker.sock
systemctl start jenkins
systemctl status jenkins
cat /var/lib/jenkins/secrets/initialAdminPassword
sudo vi /etc/sysconfig/docker
OPTIONS="-H tcp://172.31.93.144:2375 -H unix:///var/run/docker.sock"
sudo service docker restart
vi ~/.bashrc
export DOCKER_HOST='tcp://172.31.93.144:2375'
source ~/.bashrc
sudo su -
yum update -y
wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo
rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
yum upgrade -y
amazon-linux-extras install java-openjdk11 -y
yum install jenkins -y
systemctl enable jenkins
systemctl start jenkins
systemctl status jenkins
Manage jenkins : Global Tool configuration:
add maven & docker
Add dokcer & docker-compose plugins
New Job:
Name: jenkins_devops_microservice_pipeline
select pipeline option from down
select Poll SCM:* * * * *
go to Pipeline : Pipeline script from SCM
SCM:git & Repository URL : https://github.com/Haneesh55/SpringBootEcommerceApplication.git
BUILD NOW : click on link & openconsole #
sudo su -
yum install -y docker
systemctl start docker
systemctl enable docker
docker network create jenkins
In order to execute Docker commands inside Jenkins nodes, download and run the docker:dind Docker image using the following docker run command:
docker run --name jenkins-docker --rm --detach \
--privileged --network jenkins --network-alias docker \
--env DOCKER_TLS_CERTDIR=/certs \
--volume jenkins-docker-certs:/certs/client \
--volume jenkins-data:/var/jenkins_home \
--publish 2376:2376 \
docker:dind --storage-driver overlay2
docker run --name docker_dind_container --rm --detach \
--privileged --network jenkins --network-alias docker \
--env DOCKER_TLS_CERTDIR=/certs \
--volume jenkins-docker-certs:/certs/client \
--volume jenkins-data:/var/jenkins_home \
--publish 2376:2376 \
haneeshdevops/docker:dind --storage-driver overlay2
FROM jenkins/jenkins:2.401.1
USER root
RUN apt-get update && apt-get install -y lsb-release
RUN curl -fsSLo /usr/share/keyrings/docker-archive-keyring.asc \
https://download.docker.com/linux/debian/gpg
RUN echo "deb [arch=$(dpkg --print-architecture) \
signed-by=/usr/share/keyrings/docker-archive-keyring.asc] \
https://download.docker.com/linux/debian \
$(lsb_release -cs) stable" > /etc/apt/sources.list.d/docker.list
RUN apt-get update && apt-get install -y docker-ce-cli
USER jenkins
RUN jenkins-plugin-cli --plugins "blueocean docker-workflow"
b) Build a new docker image from this Dockerfile and assign the image a meaningful name, e.g. "myjenkins-blueocean:2.401.1-1":
docker build -t myjenkins-blueocean:2.401.1-1 .
Run your own myjenkins-blueocean:2.401.1-1 image as a container in Docker using the following docker run command:
docker run --name jenkins-blueocean --restart=on-failure --detach \
--network jenkins --env DOCKER_HOST=tcp://docker:2376 \
--env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 \
--publish 8080:8080 --publish 50000:50000 \
--volume jenkins-data:/var/jenkins_home \
--volume jenkins-docker-certs:/certs/client:ro \
myjenkins-blueocean:2.401.1-1
docker run --name jenkins_dind_container --restart=on-failure --detach \
--network jenkins --env DOCKER_HOST=tcp://docker:2376 \
--env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 \
--publish 8080:8080 --publish 50000:50000 \
--volume jenkins-data:/var/jenkins_home \
--volume jenkins-docker-certs:/certs/client:ro \
haneeshdevops/jenkins:dind
docker images
docker ps
docker exec jenkins-blueocean cat /var/jenkins_home/secrets/initialAdminPassword
sudo su -
yum install -y docker
systemctl start docker
systemctl enable docker
docker network create jenkins
docker run --name docker_dind_container --rm --detach \
--privileged --network jenkins --network-alias docker \
--env DOCKER_TLS_CERTDIR=/certs \
--volume jenkins-docker-certs:/certs/client \
--volume jenkins-data:/var/jenkins_home \
--publish 2376:2376 \
haneeshdevops/docker:dind --storage-driver overlay2
docker run --name jenkins_dind_container --restart=on-failure --detach \
--network jenkins --env DOCKER_HOST=tcp://docker:2376 \
--env DOCKER_CERT_PATH=/certs/client --env DOCKER_TLS_VERIFY=1 \
--publish 8080:8080 --publish 50000:50000 \
--volume jenkins-data:/var/jenkins_home \
--volume jenkins-docker-certs:/certs/client:ro \
haneeshdevops/jenkins:dind
docker exec jenkins_dind_container cat /var/jenkins_home/secrets/initialAdminPassword