Pyderman
Pyderman

Reputation: 16199

TeamCity: Can a Finish Build Trigger and a Schedule Trigger be combined?

My setup up is such that TeamCity kicks off a build on successfuil building of another project.

This works well, but now I need to constrain it such that the above only happens in a certain window during the day.

i.e. Kick off a build of Y on successful build of project X, but only between the hours of 9 and 5.

From what I can tell, I can't AND or OR two Build Triggers in order to achieve this. Does anyone know of a way around this?

Many thanks

Upvotes: 2

Views: 1832

Answers (2)

user8106179
user8106179

Reputation: 21

Another solution could be to add the first-step in build Y which will return success-code in specified interval; and next step will be executed only in this case;

Upvotes: 2

max
max

Reputation: 496

To address Justin's comment: my understanding is that you want project Y builds skipped outside of the specified time window.

I can offer the following solution:

  • Create an auxiliary build Z:
    • Build Steps. One build step: command line runner, the script checks current time and returns error level = 0 if the time is between 9 and 5, and a different error level otherwise.
    • Build Failure Conditions. Have it fail if build process exit code is not zero.
    • Build Triggering. Triggered by a successful build X.
  • Modify build Y to be triggered by a successful build Z rather than X.

This will do the trick.

However, you'll have to spend a build configuration for Z, which may be an issue if you're using the Professional Edition of TeamCity, with its limit of 20 build configurations. You could also do without creating build Z, by adding the same build step into Y, but I don't know if it's going to meet your needs. The downside is that it will cause project Y to have a number of builds failed only because it was not the right time for them. Still, you'll save CPU resources by avoiding the remaining steps of build Y (if resource saving is what you're trying to achieve).

Upvotes: 1

Related Questions