Interview Prep/CI/CD/Jenkins Pipelines and Agents

You want a nightly pipeline to be skipped when there were no new commits since the last successful run.

BeginnerScenarioJenkins Pipelines and Agents
Answer

Situation read → Pointless scheduled builds waste agents.

What I'd do →

  1. Use pollSCM('H 2 * * *') instead of cron, which only builds if the SCM has changes.
  2. Or compare the last built revision stored in a file/build description with git rev-parse HEAD and call currentBuild.result = 'NOT_BUILT'.

Why → pollSCM triggers only on a change, so you get nightly cadence without empty runs.

Interview tip → Prefer webhooks for changes and cron for time-based jobs like regression.

All CI/CD questions

More on Jenkins Pipelines and Agents