Conditional parallelism (branch-based)?



We have 2 test suites: A and B. A runs on any branch (including master), B runs only on master. The jobs are nearly identical. Trying to achieve something like this:

  • If branch not “master” - run with “parallelism: 1” and test suiteA
  • If branch is “master” - run with “parallelism: 2”, test suiteA on container 0, test suiteB in container 1

I can write separate jobs for A and B with “when” condition, but it’s a lot of duplicated code in config.yml, looking for more elegant solution.

Alternatively - I could run with “parallelism: 2” on every branch, and write our own shell file that will be called, and in the shell file do the branch/container number logic… also not very elegant…


I would go with the separate jobs for A and B with “when” condition idea, then DRY up things using Yaml aliases. Here’s an example of using a Yaml alias:

version: 2.0

  - &install-ruby-gems
    name: Install Ruby Gems
    command: bin/bundle check --path=vendor/bundle || bin/bundle install --path=vendor/bundle --jobs=4 --retry=3

# ...

        - checkout
        - run: *install-ruby-gems


This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.