Call workflows from inside a workflow (inside a script)?

We are developing a Xamarin app that will essentially be a whitelisted base for different clients (1…n). And we would like to be able to handle the deployment automatically for all clients (for which the tags and workflow chaining seem like a good fit), but we also have the possibility to add releases for specific clients (e.g. for customizations that happen between releases). Our codebase is set up such that msbuild will build everything(app customizations through bundle ID) correctly given the correct configuration, so it is mostly the signing and downstream. Is there a way to trigger this automatically?

Ideally what I would like to do is receive pull requests onto the release branch, and if they say “build_Client1, build_Client2” I would like to be able to trigger 1 build for each of these n clients. The workflow on Bitrise would be the same (just a few environment variable changes). Is something like this possible?

Hi @pfaucon,
what do you think about something like this:

format_version: "4"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

trigger_map:
- pull_request_source_branch: "build_all"
 workflow: build_all
- pull_request_source_branch: "build_Client1"
 workflow: build_Client1
- pull_request_source_branch: "build_Client2"
 workflow: build_Client2

workflows:
 build_all:
   after_run:
   - build_Client1
   - build_Client2
   ....

 build_Client1:
   envs:
   - BITRISE_XAMARIN_CONFIGURATION: ReleaseClient1
   - BITRISE_XAMARIN_PLATFORM: iPhone
   after_run:
   - _common

 build_Client2:
   envs:
   - BITRISE_XAMARIN_CONFIGURATION: ReleaseClient2
   - BITRISE_XAMARIN_PLATFORM: iPhone
   after_run:
   - _common

...

 _common:
# this workflow is the common part of your different build (git-clone, dependency install, xamarin-archive, etc..)

Using similar workflow if you create a PR with source branch build_all all of your build_Client1..n workflows will be executed.

If you create a PR with source branch build_Clientn your build_Clientn workflow will be executed which will build for your clientn.

1 Like

Sorry about the slow reply on my part @godreikrisztian

This solution would require us to have a git branch for each client? Assuming that n is large this results in a large number of branches in the git repository, especially if we have a test/release set. Although it does offer a benefit in that it is trivial to determine which version of the app a client is using, and it seems that it would play nicely with bitrise.

My main considerations are:

  • there are many clients now, so ideally we don’t want to do too much work generating redundant code
  • there (hopefully) will be more clients in the future, so we would like to keep the process for adding new ones easy. E.g. one less config file to edit actually saves a lot.
  • the current version of the application being replaced times out on builds, this should not happen

I think your solution is good, but what do you think of the edits below for addressing points 1 and 2 (a bit of pseudocode) ?

format_version: "4"
default_step_lib_source: https://github.com/bitrise-io/bitrise-steplib.git

trigger_map:
- pull_request_source_branch: "build_all"
 workflow: build_all
- pull_request_source_branch: "test_*"
 workflow: test
- pull_request_source_branch: "deployment_*"
 workflow: deployment

workflows:
 test:
   envs:
   - BITRISE_XAMARIN_CONFIGURATION: *script to extract client name, may need to be part of the steps*
   - BITRISE_XAMARIN_PLATFORM: iPhone
   steps:
# this workflow is the common part of your different build (git-clone, dependency install, xamarin-archive, etc..)

 deployment:
   envs:
   - BITRISE_XAMARIN_CONFIGURATION:  *script to extract client name, may need to be part of the steps**
   - BITRISE_XAMARIN_PLATFORM: iPhone
   steps:
# this workflow is the common part of your different build (git-clone, dependency install, xamarin-archive, etc..)

@pfaucon,
you can use a script step to branch which workflow to build as well.
In this way you would need to write a script which determines with which configuration you want to build, export this configuration and call the desired workflow.

1 Like