Jenkins - How to schedule job every period of days? - jenkins

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.

Related

How can I delete the Jenkins builds by its running duration?

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

There are too many writes to properties at this time. Please wait up to 12 hours for the changes to be processed

I am getting "There are too many writes to properties at this time. Please wait up to 12 hours for the changes to be processed." when try to read or write properties using PropertiesService class.
Originally I thought the script hit daily quotes and I stopped the script for 24 hours, but after 24 hours I got the same error, however there were no any account activity for 24 hours.
Is it still the issue with quotes ? Is it quote issues or something else ?
Thanks,
Andrey.

Jenkins bi-weekly build

How to setup jenkins job to only run biweekly at 8 AM in the morning.
Considering only the working days, Monday through Friday.
Basically running the build every second Friday.
You can use the following cron expression
0 8 8-14,22-28 * 5
The format explained looks as:
{Minute} {Hour} {DayOfMonth} {Month} {DayofWeek}
You might also want to check out Continuous Integration 101: How to Run JMeter With Jenkins for more information regarding how to set up Jenkins for JMeter tests execution.
This doesn't work, refer issue JENKINS-19756
However, a workaround that doesn't look good but works, check this answer.
Another workaround, that looks fine but works little erratically:
*0 7 1-7,15-21,29-31 * 1*
"all Mondays in 1st, 3rd and 5th week"
(error in this one: if there's a 5th week, it works its next week as well as its the first week of next month)

Find the difference between a Time and 11 am on that day

I have an ActiveSuppport::TimeWithZone object and I want to find out how many minutes after 11 AM on that day it is. So, for example, if the time is 11:47 AM, I want the answer to be 47.
Is there a way in Ruby/Rails to do this.
Thanks!
Subtracting one Time object from another gives the difference in seconds. Just divide by 60 to get minutes.
(mytime - Time.parse('11 AM')) / 60

Can Jenkins schedule builds using different time zones?

In some versions of crontab you can set the time zone for when the job should run like:
TZ=GMT
30 11 * * *
This would run at 11:30am GMT every day, even if the server was in some other time zone.
Even though Jenkins scheduling is based on cron, it doesn't seem to have this specific syntax. Is there some other way to do this in Jenkins?
Thanks
As Michael mentioned in his answer, this functionality was added. Here's an example:
TZ=Europe/Kiev
0 1 * * 5
That would run at 1:00 AM Ukraine time, once a week on Friday.
To get the names of time zones to use, you can use the column marked "TZ database name" in https://en.wikipedia.org/wiki/List_of_tz_database_time_zones
Looks like they added this in 2.60.2.
There's no way to do this in Jenkins. You could trigger the builds by calling a URL from cron though.
Edit: This has since been added; see the other answers.

Resources