Re-use build configuration in multiple build chains

I have several build chains that I want to reuse the same build configuration so I don't have to create multiple copies of it.

My build configuration starts on the dedicated test machine that launches Android Emulator, runs a specific test set and saves the report in some human-readable format. Multiple build chains want to use this build configuration: one that is triggered on Release branch creation and another from merge to dev. Is there any way that one build configuration can be used in different pipelines? There are for example two build configurations (A & B) that checkout from git, each different variant of the same repo, then one build configuration that would run the tests (T), and then another two build configurations (1 & 2), that are triggering the whole chain and providing the final decision on what to do with the test results, the android app artifact, etc.

These two flows would be for example A => T => 1 and B => T => 2.

Is the only way to achieve these chains by copying the same common build configuration? 

1
2 comments
Avatar
Permanently deleted user

If i understand your issue correct it is a conditional dependency you want. This has been requested here and in the issue tracker and so far there is no direct support afaik.

I have run into the same issue and dealt with it in two ways 

When configuring Build chain from the web UI I found extracting the common steps into templates / meta runners to be manageable effort. I.e. steps A and B in your example become two templates and you would create A1 B1 and A2 B2 respectively, only B1/2 then need to depend on 1/2.

Depending on your complexity in build this might turn into a lot of work so it might help to move to Kotlin DSL to dynamically generate your configuration. In that case you Stil can't share A and B but the duplication is almost no effort. 

0

The recommended approach at the moment would be to make a template out of T and create instances of it for every chain that needs it in the middle. I'm not really sure that conditional dependencies here (however they would be implemented) would save any work over the recommended approach of using templates. You would still need to manually manage the conditions that would trigger it and how for each of the build chains, which is no less work than creating an instance of the template and depending on that one. The template approach also allows for an easier overview of what chain builds which failed belong to.

 

Please check, watch and vote this issue in our tracker: https://youtrack.jetbrains.com/issue/TW-44985

0

Please sign in to leave a comment.