Jenkins part2
Class 22nd Jenkins May 13th
Alternative Jenkins
1.Github Actions
2.Git Lab CI/CD
3. AWS Pipeline
4.Azure Devops(pipelines)
5.CicleCI
6.Travis CI
Class 22nd Jenkins May 13th
Alternative Jenkins
1.Github Actions
2.Git Lab CI/CD
3. AWS Pipeline
4.Azure Devops(pipelines)
5.CicleCI
6.Travis CI
7.ArgoCD (for Kubernetes -based CI/CD)
Jenkins Triggers
->Jenkins triggers define how and when a Jenkins job or pipeline should start
->You can configure different types of triggers to automate the execution of builds based on events such as code commits,scheduled times,or external API calls
1.Trigger builds remotely Allows external scripts or applications to trigger Jenkins builds.
For Control and security purpose
Step1: Security token generation
In Jenkins, a Security Token (often called an API token or Crumb token) is used to authenticate and authorize automated requests to Jenkins.
A Security Token in Jenkins is like a password :
Scripts, tools, or external services (like GitHub, curl, Postman) access Jenkins
Do this without exposing your actual password
Scripts, tools, or external services (like GitHub, curl, Postman) access Jenkins
Do this without exposing your actual password
See here token generated : copy and save that token it will come again
Step2: which i have created job configuration,given the name Security key name for authorization click save
Step3:just create one file in workspace our job folder save and click build
Step4:Bulid Success
Step6: file created successfully
[root@ip-10-0-1-168 ccit-job]# pwd
/var/lib/jenkins/workspace/ccit-job
[root@ip-10-0-1-168 ccit-job]# ls -lrt
total 4
drwxr-xr-x 3 jenkins jenkins 18 May 14 03:58 src
-rw-r--r-- 1 jenkins jenkins 1541 May 14 03:58 pom.xml
drwxr-xr-x 6 jenkins jenkins 141 May 14 03:58 target
-rw-r--r-- 1 jenkins jenkins 0 May 14 06:17 ccit.txt
Step7:
Trigger builds remotely, as you here comment specified build using url also with token name
JENKINS_URL/job/ccit-job/build?token=TOKEN_NAME
http://3.252.96.43:8080/job/ccit-job/build?token=ccittoken
This is one way to Build
C:\Users\Administrator>curl -u admin:117e71fe284ff0777e2b9c5a8345c9cd09 "http://3.252.96.43:8080/job/ccit-job/build?token=ccittoken"
See here automatically build started using authentication code CLI prompt
see Build success
2.Build after other projects are built: ( it is dependency for other project,after the project compile, start build the current project) -Not covered
Configures a job to run after one or more other jobs are completed
Ensure that dependent builds are executed only when their prerequisites are succesfull.
3.Build periodically? : (Cron expression run schedule base) When to perform the build period
(*) (*) (*) (*) (*)
Min Hour DOM MOY (DOW)
Triggers a job at a scheduled time using CRON syntax
Useful for routine tasks like nightly build or scheduled maintenance jobs
MINUTE | Minutes within the hour (0–59) |
HOUR | The hour of the day (0–23) |
DOM | The day of the month (1–31) |
MONTH | The month (1–12) |
DOW | The day of the week (0–7) where 0 and 7 are Sunday. |
See here Build running every 1 mint
See here i just changed to 53 8 AM Scheduled
See here it run specific file 8:53 AM it is running
See here it run specific file 8:53 AM it is running
53 8 15(it will run 15th date) 8 (it will August month) , 3(day of the week) may be conflict 15 day is may be or may not be wed day )
0 is sun , 1 is mon,2 is tue ,3 is wed , 4 thu , 5 fir, 6 sat , 7 is again sun unix 7 is not there
4.GitHub hook trigger for GITScm polling? This is a build trigger option in Jenkins that lets GitHub notify Jenkins when new code is pushed to a repository. It’s faster and more efficient than Jenkins polling GitHub repeatedly.
Git Webbook set, whenever git commit Build done automatically ,Below Webhook give Jenkin url
and click webhook
Jar file created
[ec2-user@ip-10-0-1-168 ccit-job]$ java -jar target/ccit-0.0.1.jar --server.address=0.0.0.0 --server.port=8081
Page opened
You see here java runtime alway be run if you stop webpage not work
So it is difficult always run manually instead of that we need create service that service always run background
For that Git Index page added some text commit changes
see automatically build
[ec2-user@ip-10-0-1-168 ccit-job]java -jar target/ccit-0.0.1.jar --server.address=0.0.0.0 --server.port=8081
See change once git commit automatically build done ,but above java jar need cancel and rerun effect the changes in webpage
Jar File run automictically need to configure service
5.Poll SCM?: (it is also Same to Build periodically the difference is ,whenever Git commit Changes done then only it will trigger) SCM (source code management)
If you commit any change Git hub one id will create , The Jenkins monitor ID previous commit Id ,if any commit id changes then only build will run
If you are Build period * * * * * , date and time will capture any 1 minute
Shell script for any other example for reference
#!/bin/bash
echo "Current date and time :" $(date) >> ccit.txt
[ec2-user@ip-10-0-1-168 ccit-job]$ cat ccit.txt
Current date and time : Wed May 14 12:19:30 UTC 2025
Current date and time : Wed May 14 12:20:00 UTC 2025
Current date and time : Wed May 14 12:21:00 UTC 2025
Build after other projects are built
This decencies one trigger to another Tigger, i have created 4 job all shell touch ccit1...4 txt files
step1:
click one ccitjob1 manually ,automatically run remaining all
All dependencies job success one after another based on dependencies
All dependencies job success one after another based on dependencies
[ec2-user@ip-10-0-1-168 workspace]$ pwd
/var/lib/jenkins/workspace
[ec2-user@ip-10-0-1-168 workspace]$ ls
ccit-job ccitjob1 ccitjob2 ccitjob3 ccitjob4
├── ccitjob1
│ └── ccit1.txt
├── ccitjob2
│ └── ccit2.txt
├── ccitjob3
│ └── ccitjob3.txt
└── ccitjob4
└── ccitjob4.txt
Job Icon Legends
No comments:
Post a Comment