1

I would like to trigger a Jenkins build when the following conditions are met:

  • Time is 22:00 PM
  • A commit has occurred since the last build

I have only been able to either run it nightly (whether there has been a commit or not) using the Build periodically trigger, or only after a commit using the Poll SCM trigger or just a webhook from Stash.

I've tried using both Poll SCM and Build periodically but it ends but never running.

Does anyone have a solution for this case?

I would like my nightly to run only if there's been development activity.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Eytan Avisror
  • 2,860
  • 19
  • 26

1 Answers1

1

See Git Plugin, Environment Variables:

The git plugin sets several environment variables you can use in your scripts:

  • GIT_COMMIT - SHA of the current

  • ...

  • GIT_PREVIOUS_COMMIT - SHA of the previous built commit from the same branch

If these are the same, there was no change. Use them in the Conditional BuildStep Plugin to decide whether your nightly shall run or not.

Community
  • 1
  • 1
Gerold Broser
  • 14,080
  • 5
  • 48
  • 107
  • Good idea. This will work even though I delete the workspace before each run, correct? If I remember correctly .git folder is not deleted. – Eytan Avisror Nov 09 '15 at 08:41