How to create a Teamcity build trigger that will run job B once per week, after job A finished, where A runs daily

Viewed 297

I have some Teamcity jobs created. One of those jobs, let's call it job A, has a schedule trigger, running daily at 7:00 am.

Now I have another one, job B, that I want to run once per week, but only after job A ran.
Given that job A takes about 30 seconds to run, I know I can create a schedule trigger for job B, that will run on every Monday, at 07:10 am.
I also know I can create a Finish Build Trigger, making sure that job B runs after job A ran, but it will run every day(because job A needs to run every day)

I'm trying to find a way to combine these, and come up with some sort of trigger that does something like this:

  • runs job B once per week(say Monday morning), after job A ran.

Could someone nudge me in the right direction? Or explain to me if/why what I'd like to do is a no-no. Thanks

1 Answers

It looks like the feature called Snapshot Dependency fits well into your scenario.

To tell it short, you can link the two jobs you have with the snapshot dependency. In your case, job B will "snapshot-depend" on job A. In my experience, it works best if both jobs use the same VCS root, that is, work with the same repository.

Job A is configured to run daily and job B is configured to run weekly (via regular scheduled triggers). When job A is triggered, it doesn't affect job B at all. On the other hand, when job B is triggered, it tries to find whether there's a suitable build of A by that time. If the two jobs work with the same repo, and the Enforce revision synchronization flag is ON, this means it will try to find the build of A of that same source code revision.

enter image description here

If there's a suitable build of A, it won't trigger a new one and will just build B. If there's no suitable build of A, it will first trigger A, and then trigger the build of B.

Related