0
0
Jenkinsdevops~5 mins

Triggers directive in Jenkins - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the purpose of the triggers directive in a Jenkins pipeline?
The triggers directive is used to automatically start a Jenkins pipeline based on specific events or schedules, like a timer or a source code change.
Click to reveal answer
beginner
How do you schedule a Jenkins pipeline to run every day at midnight using the triggers directive?
Use the cron trigger inside triggers with the schedule 0 0 * * * to run the pipeline daily at midnight.
Click to reveal answer
intermediate
What is the syntax to trigger a Jenkins pipeline when a GitHub push event occurs?
Use the pollSCM trigger or configure a webhook in GitHub. In declarative pipeline, pollSCM can be set inside triggers to check for changes.
Click to reveal answer
intermediate
Can you use multiple triggers inside the triggers directive? Give an example.
Yes, you can combine triggers like cron and pollSCM inside triggers to run pipelines on schedule and on source changes.
Click to reveal answer
beginner
What happens if you omit the triggers directive in a Jenkins pipeline?
The pipeline will not start automatically. It must be started manually or triggered by other means outside the pipeline script.
Click to reveal answer
Which Jenkins pipeline directive is used to automatically start a job on a schedule?
Atriggers
Benvironment
Cstages
Dsteps
What cron expression runs a Jenkins pipeline every hour?
A0 * * * *
B* 0 * * *
C0 0 * * *
D* * * * 0
Which trigger checks for source code changes in Jenkins?
Acron
Btimer
CpollSCM
Dmanual
Can you combine multiple triggers inside the triggers directive?
ATriggers cannot be used in pipelines
BNo, only one trigger is allowed
COnly cron triggers can be combined
DYes, multiple triggers can be combined
What happens if no triggers directive is defined in a Jenkins pipeline?
APipeline runs automatically every minute
BPipeline runs only when started manually
CPipeline fails to run
DPipeline runs on every code commit
Explain how the triggers directive works in Jenkins pipelines and give an example of a scheduled trigger.
Think about how to run a job every day without clicking start.
You got /3 concepts.
    Describe how you can trigger a Jenkins pipeline when code changes happen in a Git repository.
    Consider how Jenkins knows when new code is pushed.
    You got /3 concepts.