How to trigger multiple workflows at the same time

At the time of writing, bitrise.io supports only one workflow per trigger (pull request, push to branch or tag). There is a related feature request. Fortunately this limitation can be easily mitigated.

The solution depends on your goal:

  1. You need separate workflows for some cases but sometimes you just need to run one after the other and you have enough build time (see here for more details).
    In this case you can use utility workflows, they are basically chains of the normal workflows. More info can be found on devcenter.
  2. You don’t have enough build time to accommodate all the workflows (e.g. you have mutation tests which require a lot of time).
    The solution consist of using Build Trigger API. It can be invoked for example from script step using curl command. You need a token from code tab of your app. Keep in mind that out of the box PR status checks in the workflow triggered via API will work only if you provide a commit hash however, you can add GitHub status step to that workflow.
6 Likes

Awesome guide, thanks @koral!

Just one note:

This is not true if the build is triggered with a Commit Hash. Using the API you can trigger builds without a commit hash, in that case bitrise.io can’t send the status to the git hosting service, but if the build is triggered with a specified commit hash then bitrise.io will (try to) send the build status to the support git hosting service (GitHub, Bitbucket, GitLab, …) for the specified commit.

I’ve just corrected that fragment.

1 Like

Thanks! :wink:

Hi @koral, I’m totally new to Birise and would love if could share a .yml file with the second approach, maybe in a public repository. Thanks.

1 Like

Now, there is a step for that in the Steplib. It is called Trigger Bitrise workflow.

4 Likes

@koral I’ll take a look to the docs to see if I can find something related. Thank you so much.

In the Trigger Bitrise workflow, is the Workflow ID the same as the Workflow Name?

Yes, ID is the same as name in case of workflow.
In the API documentation it is called ID:
http://devcenter.bitrise.io/api/build-trigger/#bitriseio-specific

2 Likes

One question: Is it also possible to use the utility workflows approach, if the after_run workflow is configured to use a different stack? My use case is a command line tool and I want to run tests both on macOS (workflow macOS) and on Linux (workflow Linux) which both run on different stacks. Is this possible using the utility workflow approach?

Hy! yes with different workflows you can set up different Stacks. to both macOS and linux.

Yea, you can set them but they won’t be used in the way @jamitlabs expect.
Basically utility workflow runs on the same machine as its parent. So its stack setting is ignored.

I would say that it may be a bug in workflow editor GUI that you can set stack for utility workflow. What do you think @viktorbenei ?

1 Like

Indeed, @koral is right @fehersanyi-bitrise , a build right now can only use a single stack, even if you use multiple workflows in it with different stacks. The triggered workflow’s stack will be used for the whole build.

The only way to use different stacks is to trigger a second build at the moment, as stacks are defined on a build level.

@koral well even if it’s not a bug, as technically it’s accepted, I agree that removing it from the UI would be a good idea as it might be confusing.

1 Like

Hey guys,
I’m trying figure out how can I run a few workflow parallel. I’m following the guide : https://blog.bitrise.io/start-multiple-builds-with-the-same-trigger
Everything is clear for me but the case what I want is a bit different.
I have workflows Trigger, AndroidFlavor1, AndroidFalvor2. The Trigger workflow will be triggered by event from github. The first step in that workflow is git clone repository second is Bitrise Build Start where I defined workflows that should be running in parallel (AndroidFlavor1, AndroidFalvor2). The idea is that both Android workflow uses the same code from the same repository. I want clone the repo once and run these two workflow which use the code from previous step. The problem is Android workflows fails because they can’t find code to build an app.

From guide: " This step will clone the build it is running in, but with another workflow(s) …". Correct me if i’m wrong. When I run Trigger workflow and everything what happens in that workflow should be shared with workflow AndroidFlavor1 and AndroidFlavor2. right?

Hey @rusmichal!
If you want to trigger the 2 builds at the same time, you can use two Bitrise Start Build steps, but both needs to clone the repo.

Hey
Thanks for your reply. I thought i can avoid cloning repository for any parallel workflows.

Hey!
You are welcome, the thing is that the two new workflows will start up in two totally new and different vm-s so they will not have the repo’s cloned there by a trigger workflow.

1 Like

Following up on this. It looks like this article: https://blog.bitrise.io/start-multiple-builds-with-the-same-trigger which says " This step will clone the build it is running in , but with another workflow(s) you’ve already defined and then it’ll start running these in parallel and not in succession. The build in which the step is will wait for the other(s) to finish and then if all of", it looks like I shouldn’t need to clone my code twice anymore. Can anyone confirm?

Hi @nick.teissler,

This definitely shouldn’t require you to clone your code twice :slight_smile:

Thanks @bitce, is there any updated documentation for that? It looks like the “wait for step” is redundant now, and I’m still having to clone twice :frowning: