0
0
Jenkinsdevops~20 mins

Triggers directive in Jenkins - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Triggers Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
💻 Command Output
intermediate
2:00remaining
What is the effect of this Jenkins pipeline triggers directive?
Consider this Jenkins pipeline snippet:
triggers {
  cron('H 4/4 * * 1-5')
}

What does this trigger configuration do?
Jenkins
triggers {
  cron('H 4/4 * * 1-5')
}
ASchedules the job to run every hour at 4 minutes past, Monday to Friday.
BSchedules the job to run every 4 hours on weekdays.
CSchedules the job to run at 4 AM every day from Monday to Friday.
DSchedules the job to run at 4 AM on the first five days of every month.
Attempts:
2 left
💡 Hint
Remember that 'H' is a hash-based random minute, and '4/4' means every 4 hours starting at hour 4.
🧠 Conceptual
intermediate
1:30remaining
Which Jenkins trigger directive starts a build when a GitHub push event occurs?
You want your Jenkins pipeline to start automatically when someone pushes code to GitHub. Which trigger directive should you use?
AgithubPush()
BpollSCM { cron('H/5 * * * *') }
Cupstream('other-job')
Dcron('H 0 * * *')
Attempts:
2 left
💡 Hint
Think about triggers that respond to external events rather than time schedules.
Troubleshoot
advanced
2:00remaining
Why does this Jenkins pipeline not trigger as expected?
Given this Jenkins pipeline snippet:
triggers {
  pollSCM('H/15 * * * *')
}

The job does not start automatically even though the repository has new commits. What is the most likely cause?
Jenkins
triggers {
  pollSCM('H/15 * * * *')
}
ApollSCM only schedules polling; it does not guarantee immediate builds on new commits.
BThe pollSCM trigger requires a webhook to be configured in the repository.
CThe Jenkins user does not have permission to access the repository.
DThe cron syntax 'H/15 * * * *' is invalid and causes the trigger to fail.
Attempts:
2 left
💡 Hint
Consider how pollSCM works compared to event-driven triggers.
🔀 Workflow
advanced
2:00remaining
How to configure a Jenkins pipeline to trigger after another job completes successfully?
You want your Jenkins pipeline to start only after another job named 'Build-App' finishes successfully. Which triggers directive achieves this?
Atriggers { cron('H 2 * * *') }
Btriggers { pollSCM('H/10 * * * *') }
Ctriggers { githubPush() }
Dtriggers { upstream('Build-App', 'SUCCESS') }
Attempts:
2 left
💡 Hint
Look for a trigger that listens to other job completions.
Best Practice
expert
2:30remaining
What is the best practice for using the triggers directive to avoid unnecessary builds?
Which approach best reduces unnecessary Jenkins builds when using triggers in pipelines?
ADisable all triggers and start builds manually to avoid any unnecessary runs.
BUse cron triggers only and avoid event-based triggers to keep builds predictable.
CUse event-driven triggers like githubPush() combined with minimal polling to reduce load.
DUse pollSCM with a very frequent schedule like every minute to catch all changes quickly.
Attempts:
2 left
💡 Hint
Think about balancing responsiveness and resource use.