Project: -
Install an Apache Web-server, build with Maven, Test locally/Remote &
deploy on your desired option (VM/Docker/Cloud)
Description of above DevOps plan.
1. Create Maven based source code in Gitlab.
2. Create a Jenkins job which will execute below stages.
·
Checkout code from Gitlab
·
Build/compile the source code
using Maven as a build tool.
·
scan the code
virtually.
·
Test the code by deploying an Apache
Webserver & pointing the compiled
code to
it.
·
After Successful testing, upload
the compiled code/Artifact to
Nexus Server (centralized
Server).
·
Deploy to
UAT/SIT/PROD using Ansible playbooks.
·
Deployment will be done on Docker
& further Kubernetes.
3. Nagios will monitor the above infrastructure.
========================================
Please
follow below steps to install Jenkins latest version on RHEL based VM
Prerequisites
To follow this tutorial, you will need the following:
CentOS 7 Droplet
A non-root user with sudo privileges (How To Edit the Sudoers File on Ubuntu and CentOS explains
how to set this up).
All the commands in this tutorial should be run as a non-root user. If
root access is required for the command, it will be preceded by sudo.
System-Specific Packages vs the WAR File
Now that you know what Jenkins is, you need to understand how it is distributed. Jenkins runs on Java and comes as a WAR file — a collection of related content comprising a web application and intended to be run on a server. However, the developers of Jenkins kindly extend its ease of use through a number of system-specific packages that allow Jenkins to run as a controlled service.
A Jenkins package is available for the Red Hat family of distributions,
which includes the CentOS operating systems. However, CentOS 7 in particular is
a finicky breed, so it requires a different approach. Operations that work in
other Red Hat-based OSes, even other CentOS versions, tend to work differently
in CentOS 7, and the potential errors that result can be difficult to debug.
Since the Jenkins package is generic Red Hat, rather than being differentiated
for CentOS, the likelihood of running into issues is higher than on other OSs.
For this reason, we won’t run Jenkins via this package. That leaves us the WAR
file running through Java, which is far less convenient, requiring us to
manually start and stop it through Java.
Fortunately, there’s a way around this, and even without a package, we
can work with CentOS to have it treat Jenkins like a service.
Step 1 — Installing Jenkins
There are two basic ways to install Jenkins on CentOS: through a repository, or repo, and via the WAR file. Installing from a repo is the preferred method, and it's what we'll outline first.
You'll need Java to run Jenkins (either method), so if your server
doesn't yet have Java, install it with:
·
Become Root on the Linux VM
·
yum -y install java
In general, if you need a service or tool but you're not sure what
package provides it, you can always check by running:
·
yum whatprovides service
Where service is the name of the service or tool you require.
The wget tool
downloads files into the filename specified after the "O" flag
(that's a capital 'O', not a zero).
· rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
· yum upgrade -y
· yum install epel-release java-11-openjdk-devel -y
OR
· amazon-linux-extras install epel -y
That's it! You should now be able to start Jenkins as a service:
Once the service has started, you can check its status:
This will give you a fairly lengthy readout with a lot of information on
how the process started up and what it's doing, but if everything went well,
you should see two lines similar to the following:
Loaded: loaded (/etc/systemd/system/jenkins.service; disabled)
Active: active (running) since Tue 2015-12-29 00:00:16 EST; 17s ago
This means that the Jenkins services completed its startup and is
running. You can confirm this by visiting the web interface as before, at http://ip-of-your-machine:8080.
# wget
https://download.java.net/java/GA/jdk13/5b8a42f3905b406298b72d750b6919f6/33/GPL/openjdk-13_linux-x64_bin.tar.gz
# tar -xvf openjdk-13_linux-x64_bin.tar.gz
# /opt/jdk-13/bin/java -version
# vi /root/.bashrc
export JAVA_HOME=/opt/jdk-13/
export PATH=$PATH:/opt/jdk-13/bin
# source /root/.bashrc
# echo $JAVA_HOME
# java -version
Maven
# cd /usr/local/src
# wget https://mirrors.estointernet.in/apache/maven/maven-3/3.8.1/binaries/apache-maven-3.8.1-bin.tar.gz
# tar -xf apache-maven-3.8.1-bin.tar.gz
# mv apache-maven-3.8.1/ apache-maven/
# vi /root/.bashrc
export MAVEN_HOME=/usr/local/src/apache-maven
export PATH=${MAVEN_HOME}/bin:${PATH}
# source /root/.bashrc
# mvn --version
Go to Manage Jenkins -----> Go to Global Tool Configuration
2. Set Maven_Home Path
Ref Links:-
https://www.tecmint.com/install-java-on-centos-rhel-fedora/
https://www.tecmint.com/install-apache-maven-on-centos-7/
Create a new free style job in Jenkins & add stages as mentioned in the devops architecture.
1. Checkout
2. Build
3. Execute Shell script for other stages.
Thank you !!
Comments
Post a Comment