Jenkins job trigger cron expression format is ? ? ? ? ?.
It cannot possible set the seconds unit.
But I want schedule seconds unit, like run at everyday 15:20:10.
Because there is a job with cron(0 12 * * *) and every minute job, and these two job must not to run simultaneously.
How can I do that?
Thanks for help.
you can have several options to do that :
use lock plugin to wait until your first job run will finish and only than trigger it.
use the Quiet period option in the Job configuration , add 10 seconds so the job will sleep 10 seconds after it trigger.
Related
I have a Jenkins job that sometimes runs for more than 1 hour, sometimes it just runs for few seconds. What I really need are those builds with a duration more than 1 hour.
So I would like to delete those builds with the duration less than 1 hour through e.g. the console.
I've tried a lot to find those builds. Unluckily I couldn't find a way to extract the duration information of the builds.
To get the duration of a build through the console :
build = Jenkins.instance.getItemByFullName('JOB_NAME').getBuildByNumber(BUILD_NUMBER)
println build.getDuration() // in milliseconds
println build.getDurationString() // in hour, minutes, seconds
I'd like this job to wait a certain amount of seconds based off of a string parameter given to the job. The field only allows me to enter numbers, so I cannot use $(PARAM). I want to know what would be a good way to do this.
P.S:
Do jobs in quiet period hang executors?
You could use a pipeline job that takes in the parameter and then triggers your job, setting the quiet period in the build step (see quietPeriod at the bottom). Like this:
node {
build job: 'foo',
quietPeriod: params.QuietPeriod as int,
wait: false
}
Where you've defined QuietPeriod as the parameter with the number of seconds to wait.
For those wondering about the
'P.S: Do jobs in quiet period hang executors?'
part of the original question:
No, executors are not occupied during this quiet period.
I've created a number of script syntax Jenkinsfiles with this header:
properties([
pipelineTriggers([
pollSCM('H/5 * * * *')
])
])
They almost always trigger at least twice for every commit. Once within 5 minutes of the commit, and again at +5 minutes from the first build. The builds are shorter than 5 minutes long, meaning the second build triggers after the first build has completed. Jenkins log shows both triggers as being identical, as though the second build is not aware of the first build.
I don't understand how this isn't a larger issue. It makes continuous deployment extremely dangerous. Am I missing something?
First of all, H/5 * * * * -> H means run in the next 5 mins whenever is possible. So if the build was run at 1st minute of the hour, second one may run at 6th-10th min whenever possible (Considers other jobs are running or not). And you didn't mention anything about stopping the concurrent builds also. So it will run as per your configuration.
You can stop building multiple parallel by adding this to your script.
options { disableConcurrentBuilds() }
Hope this helps.
I have a quartz job schedule like so:
_scheduler.ScheduleJob(job,
TriggerBuilder.Create().ForJob(job)
.WithSimpleSchedule(x =>
x.WithIntervalInSeconds(requeryTime.ToInt32())
.RepeatForever()
.WithMisfireHandlingInstructionNowWithRemainingCount()
)
.StartNow()
.Build())
To test I have the schedule run every 10 seconds. If I pause the service and then resume, I can still see all the jobs being called one after another. I want Quartz to ignore (do not queue) the jobs and just resume the schedule.
e.g. If the job runs every 10 secs and I pause the service for 1 minute, I get 6 jobs run in quick succession.
How do I go about ensuring Quartz ignores those jobs?
Short answer is to change the misfireThreshold in the configuration:
<add key="quartz.jobStore.misfireThreshold" value="60000" />
The default is 60000 milliseconds (60 seconds).
org.quartz.jobStore.misfireThreshold
The the number of milliseconds the scheduler will 'tolerate' a trigger
to pass its next-fire-time by, before being considered "misfired". The
default value (if you don't make an entry of this property in your
configuration) is 60000 (60 seconds).
Since your trigger runs every 10 seconds you can reduce the threshold to 9 seconds and it should work as you expect.
If you want to learn more about the strategies involved you can read this article and this one as well.
A similar question has been asked recenlty and Circular Reference gave a really good answer.
I tried to schedule a job run every 28 days but still not have solution yet.
Please help!
Thank!
As the documentation shows, using */X executes in intervals of X.
So, applying this to the "day of month" field, under "Build periodically", you could use the following to build at some consistent point in time once every 28 days:
H H */28 * 2
As an example, the 2 at the end signifies that the build should run on a Tuesday. Otherwise, it will probably build on whatever day of the week the current month started with.
I didn't try it yet so I may be wrong, but how about putting days as hours.
For example, if you want to run Jenkins job every 10 days, you schedule it to run every 240 hours.