Suppress invalid builds when there are complex dependencies

I'm having trouble suppressing "invalid" builds when using build dependency triggers.  An example would probably best illustrate this problem:

A--|
     |-->D--|
B--|---------|---->E
C------------|

In case the graph looks bad, here are the dependencies:

D depends on A and B
E depends on B, C and D

If I use build dependency triggers to trigger builds, then here's what I believe happens:

A, B & C queue
When B & C complete, E queues (twice)
When D completes, E queues again

The problem is that if the first or second E that is queued start building before D completes, it will build with the artifacts from the previous build of D, making it an invalid build.  The last build of E will be valid, but I'm not sure how to inform the customers of our builds as to which ones are valid.

I'd like to have a way to "AND" the triggers, rather than "OR" them.  So, perhaps E enters the queue as above, but only runs when all of the builds that it is dependent on have had their chance to run.  So, B & C completing might queue E, but E can't start until B, C AND D have completed.  And then it only runs once.

Have I analyzed this correctly?  Ideas for what I can do to solve my problem?

Thanks.

Please sign in to leave a comment.