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:
- https://stackoverflow.com/questions/13884568/is-it-possible-to-schedule-a-job-from-the-build-parameters-instead-of-setting-up
-
https://teamcity-support.jetbrains.com/hc/en-us/community/posts/207712685-Schedule-a-job-from-the-build-parameters-instead-of-setting-up-a-trigger
- The answer in this post mentioned a related item that was completed ("Triggered Build Customization" feature) but this doesn't actually help with what I'm trying to do.
Thank you!
Please sign in to leave a comment.
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?
Hi Guilherme Barbosa,
So for example:
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!
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!