Pre-requisites
1. Install a Webserver
Code for index.html
1.
Install & configure Jenkins Automation Server on Linux Vm.
2. Go through at some of the important options in Jenkins.
3. Manage Jenkins.
4. Plugins
5. Global Tools Configuration.
6. Credentials
7. Users
8. Slave Nodes
9. Configuring CI pipeline using Gitlab.
10. Configuring standalone CICD pipeline using.
11. Automating the CICD pipeline.
12. Jenkins log
13. Introduction to Jenkins file.
14. Basic groovy syntax & file formation.
15. Launching a Pipeline using Jenkins file.
- Create Maven based source code in Gitlab.
- 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.
Please follow below steps to install Jenkins latest
version on RHEL based VM
Step 1 — Installing Jenkins:
- Become Root on the Linux VM
- $ sudo -i
- # yum install java-1.8.0-openjdk-devel
- yum whatprovides service
service
is the name of the service or tool you require.Installing from the Repo
Now, run the following to download Jenkins from the Red Hat repo:
- wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
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
- yum install jenkins -y
Contents
Pre-requisites
1. Install a Webserver
https://gitlab.com/andromeda99/webserver
Code for index.html
https://gitlab.com/snippets/1884305
2. Maven Code
https://gitlab.com/andromeda99/maven-project1. Install & configure Jenkins Automation Server on Linux Vm.
2. Go through at some of the important options in Jenkins.
3. Manage Jenkins.
4. Plugins
5. Global Tools Configuration.
6. Credentials
7. Users
8. Slave Nodes
9. Configuring CI pipeline using Gitlab.
10. Configuring standalone CICD pipeline using.
11. Automating the CICD pipeline.
12. Jenkins log
13. Introduction to Jenkinsfile.
14. Basic groovy syntax & file formation.
15. Launching a Pipeline using Jenkinsfile.
DevOps Architecture
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.
Nexus Server (centralized Server).
Please follow below steps to install Jenkins latest version on RHEL based VM
Prerequisites
- 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).
sudo
.System-Specific Packages vs the WAR File
Step 1 — Installing Jenkins
- Become Root on the Linux VM
- yum -y install java
- yum whatprovides service
service
is the name of the service or tool you require.Installing from the Repo
- wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
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
- yum install jenkins -y
- systemctl start jenkins.service
- systemctl status jenkins.service
Loaded: loaded (/etc/systemd/system/jenkins.service; disabled) Active: active (running) since Tue 2015-12-29 00:00:16 EST; 17s ago
http://ip-of-your-machine:8080
.Please follow below steps to install OpenJDK & Maven on both Master & Slaves
OpenJDK:
# cd
/opt
# 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.5.4/binaries/apache-maven-3.5.4-bin.tar.gz
# tar -xf apache-maven-3.5.4-bin.tar.gz
# mv apache-maven-3.5.4/ apache-maven/
# vi /root/.bashrc
export MAVEN_HOME=/usr/local/src/apache-maven
export PATH=${MAVEN_HOME}/bin:${PATH}
# source /root/.bashrc
# mvn --version
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.
How to create our own workspace & use it in Jenkins other than default workspace
How to use scp command in aws ec2 instance which we
can use in our jenkins job under & "execute shell
Administrator. It usually boils down to these three things: #1) Respect the privacy of others. #2) Think before you type. #3) With great power comes great responsibility. sudo: no tty present and no askpass program specified [Pipeline] } [Pipeline] // stage [Pipeline] } [Pipeline] // withEnv [Pipeline] } [Pipeline] // node [Pipeline] End of Pipeline ERROR: script returned exit code 1
Solution:-
Go To sudoers
file at /etc/sudoers
or
just type "visudo" on shell prompt
add below mentioned Red line..after below prompt
==========
## Allow root to run any commands anywhere
root ALL=(ALL) ALL
jenkins ALL=(ALL) NOPASSWD: ALL
==========
Jenkins Logs
cat /var/log/jenkins/jenkins.log
Jenkins Installation link
https://www.jenkins.io/doc/book/installing/linux/#red-hat-centos
Comments
Post a Comment