How to have triggers with start and end date?

Hi,

I want to have different frequency triggers depending on the date for build configurations that are generated using Kotlin DSL. For example, I would want to have trigger for daily frequency then every other day then disable on certain dates. Is there a way to implement this using Kotlin DSL or REST API? 

My request is similar to these requests/use cases:

Thank you!

0
3 comments

Hi,

Can you clarify what you mean with “daily frequency then every other day”? Also, what are these certain dates, specific calendar days, week days, or something else?

 

0

Hi Guilherme Barbosa

So for example:

  • from 2024-04-01 to 2024-04-04, I want the Schedule Trigger to be set to everyday, so the cron expression could be something like “0 8 * * *” (At 08:00 everyday, trigger this).
  • from  2024-04-05 to 2024-04-08, I want the Schedule Trigger to be set to every other day, so the cron expression would be  “0 8 */2 * *”
  • On  2024-04-09, I want this build to be disabled, so the Schedule Trigger can be set to “0 8 31 2 *” (not a real date, so won't run)

In order to do this, I would need to manually change the Build Configuration setting on the day I want the new cron pattern to take effect. In the above example, on  2024-04-01 I would set the schedule trigger to “0 8 * * *”; on 2024-04-05, I would set the trigger to “0 8 */2 * *”, and on 2024-04-09, I would set the trigger to “0 8 31 2 *”.

I'm wondering how can this be automated/ implemented natively? So whether there's a way to set the Schedule Trigger to have a start and end date so the frequency can change in an automated, pre-determined fashion?

Thank you so much!

0

Hi,

I don't think it can be done out-of-the-box in a single Schedule trigger. A possible workaround could be to have the two schedule triggers (one from 2024-04-01 to 2024-04-04, and one for 2024-04-05 to 2024-04-08) defined in this build configuration, and have another build configuration where you use a command line script to enable/disable them as needed using the REST API.

The following comment explains how you can enable/disable triggers using TeamCity REST API:

https://teamcity-support.jetbrains.com/hc/en-us/community/posts/360010726199/comments/360003179019

Please let me know if this helps!

 

 

0

Please sign in to leave a comment.