Conditional Variables to improve flexibility and reduce job multiplication

Problem to solve

CI jobs frequently have different settings depending on branch or tag (only, except). This leads to job multiplication, especially when there are more reasons that need job duplication (like brand labeling). Even with templates this quickly gets hard to maintain.

Intended users

DevOps, Developers

Further details

The main goal for this proposal is to reduce job variety and get a simplified CI configuration.

Furthermore, a brief look through the issues shows that a request like "Add only/except to this or that yml field" is often requested. This proposal is a more general solution that does not require a change of the syntax of all these yml fields.

Proposal

The proposal consists of two parts:

  1. Define variables with possibly conditional values (using only, except).

    Variables:
      EXPIRE_IN:
        - value: 0
          only:
            - tags
        - value: 7 days
          only:
            - /^issue-.*$/
        - default: 30 days
      DEPLOY_TO:
        - value: components-ci
          only:
            - /^issue-.*$/
        - default: components

    The possible values are evaluated in sequence. The value of the first matching condition is used.

  2. Possibility to use variables in all yml values

    job:
      artifacts:
        expire_in: $EXPIRE_IN

~feature ~devops

Edited Apr 30, 2019 by Bernhard Roider
Assignee Loading
Time tracking Loading