Illiax
Illiax

Reputation: 992

GitlabCI run pipeline on specific branch and manual

So i am unable to specify this two things togather

build/deploy with these specific conditions.

From a specific branchb : develop And allow to run any branch from web run pipeline button.

Ive tried adding both conditions but this builds non develop branches

my_build:
  stage: build
  only: 
    - develop
    - web

If i remove web it works only on develop branch but im not allowed to run the job from web button

Has anyone achieved this before ?

Upvotes: 13

Views: 36656

Answers (3)

Chandra
Chandra

Reputation: 1

use [CI RUN] in your commmit message. Ex: git commit -m "fixed merge conflicts [CI RUN]"

Upvotes: 0

Jan Fabry
Jan Fabry

Reputation: 7351

You can do this with the rules clause, introduced in GitLab 12.3:

  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
      when: always
    - if: $CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH
      when: manual

$CI_DEFAULT_BRANCH is what you have set as the default branch in your GitLab repository settings.

See this example repo that a member of the GitLab team created.

Upvotes: 25

Thomas Löffler
Thomas Löffler

Reputation: 6144

I understand: You want to run the builds on branch develop automatically but in branch web manually?

You can't do this in one build, but you can use two builds for it:

my_build:develop
  stage: build
  only:
    - develop

my_build:web
  stage: build
  only:
    - web
  when: manual

Upvotes: 12

Related Questions