How to setup manual job from feature branch that runs automatically on master?

I have gitlab-ci similar to this:

  - test
  - build
  - deploy

  stage: test

  stage: build
    - master

  stage: deploy
    - master

Is there a way to allow at the same time:

  • always build and deploy from master
  • add manual action to build and deploy from any other branch ?

I know there is a when: manual , but is it possible to combine it like
when: manual or master ?

Combining when and only is not a good solution, because it will stop automatic build/deploy from master

1 Like

Michael -

There wasn’t an easy way to do this until the introduction of “rules” which allows for more fine-grained control over when jobs run. Rules will enable you to have more straightforward, more intuitive cases of “if / if else / else” than only: does.

To accomplish your goal, you add these two rules to the job:

      when: always
      when: manual

I’ve illustrated this in a demo repo where you can see the default branch pipeline will deploy, whereas the feature branch pipeline has the job but requires you to ‘play’ it manually.

Hope that helps!

1 Like

thanks! this is exactly what i was looking for :slightly_smiling_face:

1 Like