DevOps Training Program that will provide you with in-depth knowledge of various DevOps tools including Git, Jenkins, Docker, Ansible, Puppet, Kubernetes and Nagios. This training is completely hands-on and designed in a way to help you become a certified practitioner through best practices in Continuous Development, Continuous Testing, Configuration Management and Continuous Integration, and finally, Continuous Monitoring of software throughout its development life cycle.
Friday, 6 August 2021
Thursday, 27 May 2021
Jenkins Nexus Integration - How to integrate Nexus with Jenkins

Pre-requistes:
Install Nexus Artifact Uploader plugin in Jenkins.
Steps:
1. Once you installed the above plug-ins, click existing FreeStyle job configuration or create a new job.
2. Under source code management. enter bitbucket repo url and git credentials.
3. Go to build section, add Maven targets. with goals clean install. Also click advance, give path of POM.xml
4. click on Add build step, choose Nexus artifact uploader.
5. Enter information per below screen shot.
Make sure you enter version as 1.0-SNAPSHOT and repository as maven-snapshots. You can take the information from your WebApp/pom.xml from Bitbucket Repo
6. Click on Apply, Save.
7. Now login to Nexus repo, Click on Components, Click on maven-snapshots
8. you shall see the WAR being uploaded here.
Note:
Click here for Jenkins pipeline code for Nexus Upload.
How to Install Nexus on RedHat Linux
Here are the steps for installing Sonatype Nexus 3 in RHEL in EC2 on AWS. Please create a new Redhat EC2 instance with small type. Choose Redhat Enterprise 8.
Make sure you open port 8081 in AWS security group
Installation Steps:
Execute the below command to navigate to /opt directory by changing directory:
cd /opt
Download Nexus
sudo wget http://download.sonatype.com/nexus/3/nexus-3.23.0-03-unix.tar.gz
Extract Nexus
sudo tar -xvf nexus-3.23.0-03-unix.tar.gz
sudo mv nexus-3.23.0-03 nexus
Create a user called Nexus
sudo adduser nexus
Change the ownership of nexus files and nexus data directory to nexus user.
sudo chown -R nexus:nexus /opt/nexus
sudo chown -R nexus:nexus /opt/sonatype-work
Configure to run as Nexus user
Modify memory settings in Nexus configuration file
sudo vi /opt/nexus/bin/nexus.vmoptions
Modify the above file as shown in red highlighted section:
-Xms512m
-Xmx512m
-XX:MaxDirectMemorySize=512m
Configure Nexus to run as a service
sudo vi /etc/systemd/system/nexus.service
Copy the below content highlighted in green color.
[Install]
sudo ln -s /opt/nexus/bin/nexus /etc/init.d/nexus
Execute the following command to add nexus service to boot.
sudo chkconfig --add nexus
sudo chkconfig --levels 345 nexus on
Start Nexus
sudo service nexus start
Check whether Nexus service is running
sudo service nexus status
Check the logs to see if Nexus is running
tail -f /opt/sonatype-work/nexus3/log/nexus.log
You will see Nexus started..
If you Nexus stopped, review the steps above.
Now press Ctrl C to come out of this windows.
Click on Sign in link
Wednesday, 26 May 2021
Deploy Tomcat with Terraform
Overview
The goal is to implement Devops best practices to run Terraform in Jenkins Pipelines to deploy a tomcat. We will go over the main concepts that need to be considered and a Jenkinsfile that runs Terraform. The Jenkinsfile will consists of parameters that allows us to pass data as variables in our pipeline job.
- Install Terraform on Jenkins Server
- Install Terraform Plugin on Jenkins
- Configure Terraform
- Store and Encrypt Credentials in Jenkins
- Setting up CD Pipeline with Terraform
- Bash Script to Deploy Tomcat
- Run Pipeline Job
Install Terraform on Jenkins Server
Use the following commands to install Terraform on Jenkins server and move the binaries to the correct path as shown below.
- wget https://releases.hashicorp.com/terraform/0.12.24/terraform_0.12.24_linux_amd64.zip
- unzip terraform_0.12.24_linux_amd64.zip
- sudo mv terraform /usr/bin/
Install Terraform plugin on Jenkins
Go to Manage Jenkins > Manage Plugins >Available > search Terraform as shown below:
As you can see, Terraform Plugin is already installed on my Jenkins hence why it's displayed in the Installed section.
Store and Encrypt Credentials in Jenkins (Access and Secret Key)
In this step, we will be storing and encrypting the access and secret key in Jenkins to maximize security and minimize the chances of exposing our credentials.
- Go to Manage Jenkins > Manage Credentials > Click on Jenkins the highlighted link as shown below
- Select Add Credentials
- Choose Secret text in the Kind field
- Enter the following below:
- Secret = EnterYourSecretKeyHere
- ID = AWS_SECRET_ACCESS_KEY
- Description = AWS_SECRET_ACCESS_KEY
- Secret = EnterYourAccessIDHere
- ID = AWS_ACCESS_KEY_ID
- Description = AWS_ACCESS_KEY_ID
Click OK
Configure Terraform
Go to Manage Jenkins > Global Tool Configuration > It will display Terraform on the list.
- Enter terraform in the Name field
- Provide the path /usr/bin/ as shown below

- Go to Jenkins > New Items. Enter tomcat-pipeline in name field > Choose Pipeline > Click OK
Bitbucket Changes
- Create a new Bitbucket Repo and call it tomcat-pipeline
- Go to Repository Settings after creation and select Webhooks
- Click Add Webhooks
- Enter tf_token as the Title
- Copy and paste the url as shown below
- Status should be active
- Click on skip certificate verification
- triggers --> repository push
- Go back to Jenkins, select Pipeline Script From SCM
- Enter credentials for Bitbucket, Leave the Branch master as the default, Make sure script path is Jenkinsfile
- Right click on Pipeline Syntax and open in a new tab.
- Choose Checkout from Version Control in the Sample Step field
- Enter Bitbucket Repository URL and Credentials, leave the branches blank
- Click GENERATE PIPELINE SCRIPT, copy credentialsId and url (This is required for Jenkinsfile script)
Open Visual Code Studio and click on
Terminal
- Navigate to tomcat-pipeline repo in Bitbucket
- Run the command before cloning repo: git init
- Clone the repo with SSH or HTTPS
Create a new file main.tf and copy the below code in yellow color
region = var.region
version = "~> 2.0"
}
resource "aws_instance" "ec2" {
user_data = base64encode(templatefile("deploy.sh", {JAVA_HOME = var.java_home}))
ami = "ami-0782e9ee97725263d" ##Change AMI to meet OS requirement as needed.
root_block_device {
volume_type = "gp2"
volume_size = 200
delete_on_termination = true
encrypted = true
}
tags = {
Name = "u2-${var.environment}-${var.application}"
CreatedBy = var.launched_by
Application = var.application
OS = var.os
Environment = var.environment
}
instance_type = var.instance_type
key_name = "Enter_KEYPAIR_Name_Here"
vpc_security_group_ids = [aws_security_group.ec2_SecurityGroups.id]
}
output "ec2_ip" {
value = [aws_instance.ec2.*.private_ip]
}
output "ec2_ip_public" {
value = [aws_instance.ec2.*.public_ip]
}
output "ec2_name" {
value = [aws_instance.ec2.*.tags.Name]
}
output "ec2_instance_id" {
value = aws_instance.ec2.*.id
}
- Create a new file security.tf and copy the below code in yellow color.
name = "u2-${var.environment}-sg-${var.application}"
description = "EC2 SG"
ingress {
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
to_port = 4000
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
ingress {
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
#Allow all outbound
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
}
- Create a new file variable.tf and copy the below code in yellow color.
type = string
default = "us-east-2"
}
variable "instance_type" {}
variable "application" {}
variable "environment" {}
variable os {
type = string
default = "Ubuntu"
}
default = "USER"
}
############## end tags
Bash Script to Deploy Tomcat and Java application
- Create a new file deploy.sh and copy the below code in yellow color.
- Create a new file Jenkinsfile and copy the below code in yellow color.
- Commit and push code changes to Repo with the following:
- In Vscode, navigate to Source Code Icon on the right tabs on the side
- Enter commit message
- Click the + icon to stage changes
- Push changes by clicking on the 🔄0 ⬇️ 1 ⬆️ as shown below
- Go to tomcat-pipeline on Jenkins and run build
- Enter AppName
- Select a Branch/Lifecycle to deploy server
- Choose instance size for the server.
- Go to Console Output to track progress
How to upgrade Maven
java.lang.IllegalStateException I had installed maven in my ubuntu using command apt install maven This installed maven in path /usr/shar...
-
SQL Fundamentals Course SQL Fundamentals Course Documentation Table of Contents ...
-
ONLY 10 SLOTS AVAILABLE!!!!! 🎉✨ **Limited Time Offer: Supercharge Your DevOps Skills for Less!** ✨🎉 Are you ready to level up your DevO...
-
java.lang.IllegalStateException I had installed maven in my ubuntu using command apt install maven This installed maven in path /usr/shar...


























