Starting Fan-Out/Parallel jobs conditionally

#1

Hello,
I need to fan-out 2 jobs (lets say A and B) in parallel via build-router-start/build-router-wait but one of the job (B) should be run only if the condition X is true.

I thought I could do this with the following steps:

  1. Script: Evaluate the condition X and if true add the env variable START_BUILD
  2. Bitrise start build: Start job A
  3. Bitrise start build: Start job B, only if the env START_BUILD is true via run_if
  4. … do sth on main workflow…
  5. Wait for build: Wait for job B, run_if START_BUILD is true
  6. Wait for build: Wait for job A

Now the problem is that I do not know how to correlate start/wait with job A, and start/wait with job B. Running second “Bitrise start build” (B) overwrites the first one (A) so wait step only waits for the second job (B).
The other solution I thought would be to run single “Bitrise start build” with 2 workflows specified A and B, but not sure how to insert the condition for job B there.

Is there any other way I can address this problem or perhaps I’m missing sth in the approaches above?

0 Likes

#2

In point 1. instead of boolean result START_BUILD you can construct a string with workflow names which will contain either A or A \n B, then pass this as a workflows Bitrise start build step input.

0 Likes

#3

You are right, its possible to enter a viariable there. Thank you!

0 Likes