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

20,937

Solution 1

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.

Solution 2

I got you fam: crontab.guru

10 22 1-7,14-21,28-31 * 6

Solution 3

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.

Share:
20,937
JeffH
Author by

JeffH

merge keep Software Craftsman Generalizing Specialist Agile Software Developer / Coach

Updated on November 08, 2020

Comments

  • JeffH
    JeffH over 3 years

    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?