Jenkins - Part-2

Build triggers:
Cloud Build uses build triggers to enable CI/CD automation. You can configure triggers to listen for incoming events, such as when a new commit is pushed to a repository or when a pull request is initiated, and then automatically execute a build when new events come in.
Important( widely used build triggers) Build triggers are:
→ Build Periodically
→ GitHub Hook Trigger
→ Poll SCM
Build Periodically:
At the scheduled time, it is going to execute the job.
here we schedule the time, when the trigger has to happen, in which time interval the job will execute.
Poll SCM :
→ It will only Build unless and until, there is a new commit id. i.e., if there is a new code added in the remote repository then only the poll SCM will execute the job.
→ If we mention a scheduled time in that time period it check for the new commit id, if there is any new code change in the remote repository then the job will execute in that scheduled time period.
→ The only disadvantage of this is, it is overload to the jenkins, as the jenkins has to run the job in every scheduled time and get the commited changes from the Git.
GitHub Hook Trigger: / Web Hooks
→ Here instead of jenkins contact the git hub to find the changes in code, the SCM itself only inform the Jenkins that there is a code change in the repository.
→ For creating the web hooks, first we need to select the Github hook in the triggers, then we define the settings the git hub(SCM repository).
→ open git repository select settings, in settings we can see the web hook option, click on that
→ click on Add webhook
→Here in payload url, mention the jenkins url
The web hook is created, whenever there is change in the code, now SCM informs the jenkins and jenkins will execute the job.
→ When we build the jobs, it maintains all the details regarding the job, and it is a overloading issue, as it consumes more memory, so we can have the option like ‘discard old builds’, here we can discard the old builded jobs in order to give memory space to the jenkins.
→ Max of builds to keep is how many builds we need to maintain in the jenkins, in above we have given 5 as the last 5 builds only maintain in the jenkins.
Plugin:
→ Jenkins plugins are the components of the Jenkins environment. Plugins are small, independent programs that can improve and extend the functionality of Jenkins CI/CD. There are over 1,900+ Jenkins plugins available right now and it keeps on increasing month by month.
→We can define the code coverage details, the changes will trigger before code deploying into the soarqube.
Jocaco plugin
Elastic IP’s- Elastic IP’s are static, if we set elastic ip’s to the server even if we stop and start the server, the public ip won’t change.
Safe restart plugin:
when we use it get forcefully restart thesystem, the jobs that are under progress that will get interupted but when we use safe restart it will wait untill the job execution is completed or the job is paused then it will restart the jenkins.
→ we need to install the safe restart plugin in the jenkins
Maven integration:
used to integrate a java based projects. Provides integration between maven and jenkns
sshAgent plugin- The jenkins can programatically SSH to any server.
AuditTrail - To know who is performing what action in the jenkins.
Buildwith parameters-
→ Note: in above image, branch specifier use {} instead of ()braces.
Blue ocean plugin-
Setting up the notification:
→ Sending Notification- the developers gets the notification regarding the job execution status like, it is successful or a failure.
some types are
→ EMail notification
→ Slack notification
→ MS Team notification
EMail notification:
→ we have to install a plugin called e-mail extension
→ SMTP( simple mail transfer protocal)
→ Now we have to connect the SMTP server.
→desktop→ manage jenkins→ system→ there we can set the SMTP server details
→ we need to check for the 2 factor authentication is on or off in the mail that we want to send notifications.turn it on if it not turned off.
→search for app password in the gmail and create a new one.
→ After doing system level configurations need to configure the settings in the job
→ Now execute the job
Subscribe to my newsletter
Read articles from Sandhya Kalikiri directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
