Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 3

1.

Setup EC2 instance - Install Java, Install Jenkins, Start Jenkins, Access Web UI
on port = 8080

a. Ensure that your software packages are up to date on your instance ==> sudo yum
update –y
Add the Jenkins repo ==> sudo wget -O /etc/yum.repos.d/jenkins.repo
https://pkg.jenkins.io/redhat-stable/jenkins.repo
Import a key file from Jenkins-CI to enable installation from the package ==>
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key; sudo yum
upgrade

b. Install Java ==> sudo amazon-linux-extras install java-openjdk11 -y

c. Install Jenkins ==> sudo yum install jenkins -y


Enable the Jenkins service to start at boot ==> sudo systemctl enable jenkins
Start Jenkins as a service ==> sudo systemctl start jenkins
Check the status of the Jenkins ==> sudo systemctl status jenkins

d. Connect to http://<your_server_public_DNS>:8080 from your browser


/var/lib/jenkins/secrets/initialAdminPassword

e. Configure Jenkins
Install Amazon EC2 plugin
Configure a cloud
Add a new cloud = Amazon EC2
AWS EC2 Credentials -> Add:
select Kind = AWS Credentials and add IAM User
programmatic access keys with permissions to launch EC2 instances = Access Key and
Secret Key
Region -> Select
EC2 Key Pair’s Private Key -> Add:
select Kind = SSH Username with private key and add
the Private-Key
Test Connection = Success

f. Run First Jenkins Job


Script = echo "Hello! Welcome to Jenkins World!"
Build Now - Job should run successfully and see the above output in the
console

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------

2. Install Git with Jenkins

a. Install git on jenkins server => sudo yum install git -y; git version

b. Run Git Jenkins Job


Source Code Management - select Git, add Repository URL (if unable to
add, then add the git path to the Global Configurations)
Build Now - Job should run successfully and see the above output in the
console

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------

3.

sudo cd /var/lib/maven
sudo wget https://dlcdn.apache.org/maven/maven-3/3.9.0/binaries/apache-maven-3.9.0-
bin.tar.gz

sudo tar -xvzf apache-maven-3.9.0-bin.tar.gz

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------

sudo vim ~/.bash_profile

sudo update-alternatives --config java


/usr/lib/jvm/java-11-openjdk-11.0.18.0.10-1.amzn2.0.1.x86_64/bin/java

/opt/apache-maven-3.9.0

source ~/.bash_profile

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------

Build and check if you are able to connect to Gitlab and get the code

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------

4.

sudo amazon-linux-extras install java-openjdk11 -y

sudo su -

cd /opt

wget https://dlcdn.apache.org/tomcat/tomcat-9/v9.0.72/bin/apache-tomcat-
9.0.72.tar.gz

tar -zvxf apache-tomcat-9.0.72.tar.gz

cd apache-tomcat-9.0.72/bin/

chmod +x startup.sh
chmod +x shutdown.sh

ln -s /opt/apache-tomcat-9.0.72/bin/startup.sh /usr/local/bin/tomcatup
ln -s /opt/apache-tomcat-9.0.72/bin/shutdown.sh /usr/local/bin/tomcatdown

tomcatup

cd ..

find -name context.xml

./conf/context.xml
./webapps/examples/META-INF/context.xml
./webapps/host-manager/META-INF/context.xml
./webapps/manager/META-INF/context.xml

#comment value tag sections in below all files

vi ./webapps/examples/META-INF/context.xml
vi ./webapps/host-manager/META-INF/context.xml
vi ./webapps/manager/META-INF/context.xml

cd apache-tomcat-9.0.55
cd conf

vi tomcat-users.xml

#Add below lines between <tomcat-users> tag

<role rolename="manager-gui"/>
<role rolename="manager-script"/>
<role rolename="manager-jmx"/>
<role rolename="manager-status"/>
<user username="admin" password="admin" roles="manager-gui,manager-script,manager-
jmx,manager-status"/>
<user username="deployer" password="deployer" roles="manager-script"/>
<user username="tomcat" password="s3cret" roles="manager-gui"/>

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------

Download plugin - Deployer

Create creds
Add tomcat deatils and build
cd webapps - here war file gets deployed

-----------------------------------------------------------------------------------
-----------------------------------------------------------------------------

CICD:

Change code in GIT UI : Build the job(PULL SCM - */2 * * * *)


Change the code in GIT-BASH and Push it to Git -> Jenkins automatically deploys to
Tomcat after 2mins

You might also like