Jenkins Popular Build Triggers Automate the CICD Pipeline
Introduction:
Jenkins build triggers allow for the automation of builds and deployments based on specific events or conditions. With Jenkins build triggers, you can initiate builds when changes are made to a repository, on a schedule, or when triggered by external factors like webhook notifications.
Benefits of using Jenkins build triggers include improved efficiency and productivity through automated build processes, faster feedback loops for developers, the ability to integrate with various tools and services, and the flexibility to customize build triggering based on specific requirements.
Some Popular Triggers:
1- Git webhook
2- Poll SCM
3- Scheduled job
4- Remote triggers
5- Build After other project are build.
Steps:
Now time to create the pipeline:
But this time not with the script but using SCM:
And select ssh username with private key: username will be your github account and paste private key from your laptop as instead your laptop now jenkins will clone or pull the github code:
Now select credentials that created just now with username and private key:
Now give the path of script that is at github , our it at main root page so just give the file name:
Save and build the job.
Build Triggers:
Note: allow port 8080 from anywhere on SG of jenkins server.
Now go to your jenkins job→ configure→ build trigger
Job executed:
2- Poll SCM:
It works similar to webhook but opposite means in this case github is triggering the job and jenkins will check for commits.
Now we will select pol scm option in jenkins job build trigger option and define time whenever it runs:
3- Schedule Job:
It is similar to pol scm but it is ot going to check your source code manager it just run the job at particular
4- Remote triggers:
From anywhere you can trigger that jenkins job.
example:
Now run this curl command from your laptop terminal: