Jenkins
Class 21st Jenkins May 12th
Jenkins is an open-source automation server that helps developers build,test, and deploy software efficiently.
it enables continuous integration (CI) and continuous development(CD)by automating tasks like pulling code from a repositry building application,running tests, and deploying software to production
Key Features of Jenkins
1.Automated Build & Deployment :Jenkins automates the process of compiling.testing and deploying the application
2.Plugin support - Jenkins has a vast eco system of plugins to integrate with tools like git,docker ,kubernetes ,Aws ,and more
How Jenkins works?
1. Developers push code to a repository (e.g Gut hub ,Git lab or Bitbucket)
2.Jenkins detects the change and triggers a job to fetch the latest code
3.Jenkins builds the application using tools like maven,Gradle,or npm
4.Jenkins run automated test to check code quality
5.Jenkin notification:
Default path /var/lib/jenkins
https://www.jenkins.io/
https://www.jenkins.io/doc/book/installing/linux/
Step1: Long term support
sudo wget -O /etc/yum.repos.d/jenkins.repo \
https://pkg.jenkins.io/redhat-stable/jenkins.repo
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
sudo yum upgrade
# Add required dependencies for the jenkins package
sudo yum install fontconfig java-21-openjdk
sudo yum install jenkins
sudo systemctl daemon-reload
default path for Jjenkins /var/lib/Jenkins
Step2: Maven though some application building and developing the artifacts
get the pom.xml from git repo
[root@ip-10-0-1-168 ~]# sudo wget -O /etc/yum.repos.d/jenkins.repo \
> https://pkg.jenkins.io/redhat-stable/jenkins.repo
[root@ip-10-0-1-168 ~]# sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key
[root@ip-10-0-3-152 ec2-user]# yum install -y java-17-amazon-corretto-devel
[root@ip-10-0-3-152 ec2-user]# yum install -y git
[root@ip-10-0-1-168 ~]# sudo yum install jenkins
--click y
Status for Jenkins
[root@ip-10-0-1-168 ~]# systemctl status jenkins
● jenkins.service - Jenkins Continuous Integration Server
Loaded: loaded (/usr/lib/systemd/system/jenkins.service; disabled; vendor preset: disabled)
Active: inactive (dead)
May 14 01:59:03 ip-10-0-1-168.eu-west-1.compute.internal systemd[1]: [/usr/lib/systemd/system/jenkins.service:16] Unknown lval...nit'
May 14 01:59:03 ip-10-0-1-168.eu-west-1.compute.internal systemd[1]: [/usr/lib/systemd/system/jenkins.service:17] Unknown lval...nit'
May 14 01:59:55 ip-10-0-1-168.eu-west-1.compute.internal systemd[1]: [/usr/lib/systemd/system/jenkins.service:16] Unknown lval...nit'
May 14 01:59:55 ip-10-0-1-168.eu-west-1.compute.internal systemd[1]: [/usr/lib/systemd/system/jenkins.service:17] Unknown lval...nit'
Hint: Some lines were ellipsized, use -l to show in full.
Showing inactive make active
[root@ip-10-0-1-168 ~]# systemctl start jenkins
[root@ip-10-0-1-168 ~]# systemctl status jenkins
Step3: Jenkins default port is 8080
here telling Jenkins unlock and get password given below path, get the key ,give the key password
click continue
Step4: [root@ip-10-0-1-168 ~]# cd /var/lib/jenkins/secrets/
[root@ip-10-0-1-168 secrets]# ls
initialAdminPassword jenkins.model.Jenkins.crumbSalt master.key
[root@ip-10-0-1-168 secrets]# cat initialAdminPassword
ec84ee9900ef4cdbb741172024bb0405
Click install suggested plugins ,it Getting started installations
Step5:
It is just like AWS im user's here iam creating amin user and some email-id save and continue
this your Jenkins url http://3.252.96.43:8080/ click save and Finish and start using jenkins
Jenkins dashboard we creating jobs ,we have git repo need to build deploy it
Manage Jenkins , we have some warning java 17 not support like information just ignore,
System configuration ,
node multiple server build purpose using
plugins special software msbuild like we get from here
Tools >we have inbuilt software available maven/Ant /Gradle/Git
Give name any and save just configured
here different configuration ,Triggers
Triggers
Trigger builds remotely (e.g., from scripts) ? For you job running give one url for secure give Authentication Token, based on token it will run
Build after other projects are built? for multiple project ,we can give one by one
Build periodically? ,We give time period just like crontab
GitHub hook trigger for GITScm polling?( Our Git repos webhook we have to configure, so that whenevery you give commit , our build will run we just give jenkins url in the git) like this way we will do practical later
Poll SCM? it is also Cron periodically ,the difference build periodically it schedule every time
if change doesnot matter it will run ,poll scm only whenevery git commit change happen only triggered and build
Build Steps (Shell scripting , we can able given manually maven installation if you not added maven plugins..etc)
Step7:
I did not any change click save and build went success
Step8: Created job give below confirguration and save buid
Step9:Build success
Step10:See here maven target folder created [root@ip-10-0-1-168 target]# pwd
/var/lib/jenkins/workspace/ccit-job/target
[root@ip-10-0-1-168 target]# ls -lrt
total 19660
drwxr-xr-x 3 jenkins jenkins 25 May 14 03:58 generated-sources
drwxr-xr-x 3 jenkins jenkins 35 May 14 03:58 maven-status
drwxr-xr-x 4 jenkins jenkins 34 May 14 03:58 classes
drwxr-xr-x 2 jenkins jenkins 28 May 14 03:58 maven-archiver
-rw-r--r-- 1 jenkins jenkins 3700 May 14 03:58 ccit-0.0.1.jar.original
-rw-r--r-- 1 jenkins jenkins 20125836 May 14 03:58 ccit-0.0.1.jar
Step11: execute jar file 8080 already jenkins running given different port 8081
java -jar target/ccit-0.0.1.jar --server.address=0.0.0.0 --server.port=8081
[root@ip-10-0-1-168 target]# ls
ccit-0.0.1.jar ccit-0.0.1.jar.original classes generated-sources maven-archiver maven-status
[root@ip-10-0-1-168 target]# cd ..
[root@ip-10-0-1-168 ccit-job]# java -jar target/ccit-0.0.1.jar --server.address=0.0.0.0 --server.port=8081
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v3.0.5)
Step12: See here below our website hosted
This Simple Java Webpage successfully Build
--Thanks
No comments:
Post a Comment