Reputation: 237
Is there a way to trigger a scheduled job?
I am building a pipeline of connected jobs which trigger each other once complete. I want one of the jobs to be scheduled to run at a particular time of the day. So I want to be able to essentially add to a queue to trigger at a later time.
Is that possible?
Cheers
Upvotes: 0
Views: 1441
Reputation: 25491
You could use the Jenkins Workflow plugin suite (mentioned in your tag, perhaps unintentionally). It has a sleep
step. If you wanted the next stage of the pipeline to run at a particular time of day, rather than after a fixed interval, you could do some simple computation with java.util.Calendar
to determine the seconds between now and then.
Upvotes: 0
Reputation: 194
To schedule a Jenkins job to run at a specific time, go to the job's landing page, click Configure from the left-side menu, scroll down to 'Build Triggers' section and pick 'Build Periodically'.
There you can specify the cron job formatted string to denote when and how often you'd like this first job to be scheduled for running.
If that job is not the first job in line, you can always use 'Quiet Period' option under 'Advanced Project Options' which puts in a delay in that job before the build steps actually run. You can specify the number of seconds you want that job to wait for before it actually executes.
This plugin seems to be piggybacking on the 'Quiet Period' feature though I haven't tried it myself: https://wiki.jenkins-ci.org/display/JENKINS/Schedule+Build+Plugin. You might have luck using it to your advantage.
Upvotes: 1