Can I set Jenkins' "Build periodically" to build every other Tuesday starting March 13?
Asked Answered
R

4

7

I want to schedule Jenkins to run a certain job at 8:00 am every Monday, Wednesday Thursday and Friday and 8:00 am every other Tuesday.

Right now, the best I can think of is:

# 8am every Monday, Wednesday, Thursday, and Friday:
0 8 * * 1,3-5

# 8am on specific desired Tuesdays, one line per month:
0 8 13,27 3 2
0 8 10,24 4 2
0 8 8,22 5 2
0 8 5,19 6 2
0 8 3,17,31 7 2
0 8 14,28 8 2
0 8 11,25 9 2
0 8 9,23 10 2
0 8 6,20 11 2
0 8 4,18 12 2

which is is fine (if ugly) for the remainder of 2012, but it almost certainly won't do what I want in 2013.

Is there a more concise way to do this, or one that's year-independant?

Rialto answered 1/3, 2012 at 17:36 Comment(0)
D
4

This is something that comes up quite often, see e.g. this document, this forum thread or this stackoverflow question.

The answer is basically no. What I would do in your situtation is to run the job every Tuesday and have the first build step check whether to actually run by e.g. checking whether a file exists and only running if it doesn't. If it exists, it would be deleted so that the job can run the next time this check occurs. You would of course also have to check whether it's Tuesday.

Doff answered 1/3, 2012 at 21:42 Comment(0)
E
3

I got you fam: crontab.guru

10 22 1-7,14-21,28-31 * 6
Emphysema answered 7/11, 2017 at 15:50 Comment(1)
You're 1-off. Should be 1-7,15-21,29-31. Will run two weeks in a row if it matches on 29-31 though.Farceuse
N
1

If you abandon every other Tuesday, and can be satisfied with the first and third Tuesdays a month, the following should work: 0 9 1-7 * 2 0 9 15-21 * 2

You're running every day from 1-7, but only on Tuesday, and every day from 15-21, again only on Tuesday. A Tuesday will occur only once in each of those intervals.

Yes, it's not strictly every other week, as a 5-Tuesday month will throw off your cadence, but here you have a predictable job schedule that doesn't need to be adjusted in Jenkins as time goes on.

Nagana answered 3/8, 2016 at 13:9 Comment(0)
C
0

I use Excel to generate the cron expressions. The following formulas generate every other Monday at 8:00 AM starting from Oct 22.

      A      B              C               D
1    41204  =MONTH(A1)  =DAY(A1)        =CONCATENATE("0 8 ", C1, " ", B1, " 1")
2    =A1+14 =MONTH(A2)  =DAY(A2)    =CONCATENATE("0 8 ", C2, " ", B2, " 1")

This generates

    A       B       C       D 
1   22-Oct  10  22  0 8 22 10 1
2   5-Nov   11  5   0 8 5 11 1

Just auto fill Row 2 to get additional days. I'm not sure how many separate expressions you can give to Jenkins. I know it works with 26 expressions.

Cordeelia answered 15/10, 2012 at 19:2 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.