gitlabyamlgitlab-ci

Gitlab CI run job automatically on main branch and allow manual job for other branches


It is often handy to have job running on main branch, but allow for manual exectution on other branches. How to do it?


Solution

  • You can use rules:if:

    my-job:
      rules:
        - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
          when: always
        - when: manual # otherwise run manually