Javascript required
Skip to content Skip to sidebar Skip to footer

How to Install Jenkins With Tomcat in Ubuntu

Home / How To / How to install Jenkins with a .war file in AWS EC2 Ubuntu 20.04 instance

How to install Jenkins with a .war file in AWS EC2 Ubuntu 20.04 instance

How To 29 Views

Jenkins is an open source tool for continuous integration and continuous distribution. It is an automation tool that helps to build, test and distribute software reliably. It is written in Java and comes with hundreds of plugins. Jenkins also supports the distribution of work across multiple servers. It's very easy to configure Jenkins and get started. In this article, we will install Jenkins with the .war file in Apache Tomcat. We will use AWS EC2 Ubuntu 18.04 server to perform this activity. You can even use a virtual machine on your local machine or remote server with Ubuntu 18.04 on it.

Conditions

  1. AWS account (Create if you do not have one).
  2. An EC2 instance (Click here to learn how to create an EC2 instance) or a virtual machine with at least 256 MB of RAM and 1 GB of hard disk space.

What should we do?

  1. Download the Jenkins and Apache Tomcat package.
  2. Install Java and initialize Apache Tomcat with Jenkins.
  3. First installation by Jenkins.

Download the Jenkins and Apache Tomcat package

Before we begin the installation, let's check the OS version and see if Java is available on the server with the following commands.

cat / etc / problem

java

Check the OS version

Check the current user you are logged in with and switch to "root" user.

who am I

sudo -i

who am I

Create a new directory in / opt / where we download Jenkins and Apache Tomcat packages.

cd / opt /

mkdir jenkins

cd jenkins /

pwd

Create a folder

Go to the Jenkins download page and get the URL of the war file to download the Jenkins package

https://www.jenkins.io/download/

In this case, the following URL is for downloading Jenkins' war file.

https://get.jenkins.io/war-stable/2.263.4/jenkins.war

Download the jenkins.war download URL

You can now use the "wget" command to download the war file to your server.

wget https://get.jenkins.io/war-stable/2.263.4/jenkins.war

ls -l

Download the jenkins.war file to the server

Go to the Apache tomcat website to download the package. We use the Apache Tomcat 9 package.

https://tomcat.apache.org/download-90.cgi

Download the URL to download the Apache-Tomcat package

Download the URL of the package and download it to the server with "get".

wget https://downloads.apache.org/tomcat/tomcat-9/v9.0.43/bin/apache-tomcat-9.0.43.tar.gz

ls

Download the Apache-Tomcat package

Install Java and initialize Apache Tomcat with Jenkins

Apache Tomcat requires Java to run, so before proceeding we need to install java on the server.

Use the following command to update the system.

apt update

After updating the system, install Java 8 on Ubuntu with the following command.

apt install openjdk-8-jdk

Install OpenJava 8

Check the Java version to make sure Java is installed.

java version

ls

Check the Java version

Now we are ready to use Apache Tomcat. Extract the tar file that we downloaded in the previous step.

tar -zxvf apache-tomcat-9.0.43.tar.gz

ls

Extract the Apache-Tomcat package

Move / copy Jenkins war file to the Apache Tomcat web app directory.

mv jenkins.war apache-tomcat-9.0.43 / webapps /

ls

ls -lt apache-tomcat-9.0.43 / webapps /

Move jenkins.war to the webapp directory

We are now ready to launch Apache Tomcat. Before that, let's see if the 8080 used by Apache Tomcat is free or not.

cd apache-tomcat-9.0.43 / bin /

netstat -tulpn | grep 8080

If no other service is running on 8080, we are ready to launch Apache Tomcat.

Use the following command to start the service.

./startup.sh

Check if the service has started.

netstat -tulpn | grep 8080

Launch Apache-Tomcat

Check that Apache Tomcat has started successfully and that there are no errors in the logs.

tail -100f ../logs/catalina.out

Check the Apache-Tomcat logs

We need to do the first installation of Jenkins, to do that we need to use the password available in "initialAdminPassword".

Get the password required to log in to Jenkins. You can see the "initialAdminPassword" file path in the Apache Tomcat logs.

cat /root/.jenkins/secrets/initialAdminPassword

You can also check if the Apache process is running, use the following command.

ps -ef | grep apache

Download Jenkins AdminPassword

To access Jenkins on Port 8080, we must ensure that the incoming connection on the port is allowed in the EC2 instance security group.

Allow connection to Port 8080 in the security group in the EC2 instance

Obtain the public IP address of the EC2 instance.

Obtain the public IP address of the EC2 instance

First installation by Jenkins

Go to Jenkins at http: //: port / jenkins

http://52.87.233.129:8080/jenkins

Enter the password retrieved from the "initialAdminPassword" file.

Access and unlock Jenkins

Customize Jenkins and install suggested plugins. It takes some time.

Install suggested plugins

You can create a new administrator user or skip user creation and continue with the current administrator user and password.

Continue with Admin users

Keep the URL as it is and click "Save and Finish".

Keep the default Jenkins URL

Now Jenkins is ready to use.

Jenkins is ready

Here you see Jenkins Dashboard.

Jenkins main instrument panel

Conclusion

In this article, we looked at the steps to install Jenkins with the .war file. We performed this activity on the AWS EC2 Ubuntu 18.04 server. We installed Java required by Jenkins and used Apache Tomcat to distribute the jenkins.war file. We logged in with the Admin user and did the first installation of Jenkins with the suggested plugins.


Source link

2021-03-05

How to Install Jenkins With Tomcat in Ubuntu

Source: https://howtosanta.com/how-to-install-jenkins-with-a-war-file-in-aws-ec2-ubuntu-20-04-instance/