0
votes

Problem: I have two jobs in my pipeline, which I want to run only by "Run pipeline" button I need to run this jobs for any branch. But when I choose any non-master branch, gitlab show me "Pipeline cannot be run. No stages / jobs for this pipeline."

First, I configured jobs with no 'rules' keyword but with 'only' keyword:

  only:
    refs:
      - api
      - web

What I have to do to make my manual-triggered pipeline runnable?

My resent CI:

stages:
  - test
  - publish


.run_branch_from_gui:
  only:
    - branches
    - tags
  except:
    - master
  when: manual

compile_and_test_branch_manually:
  stage: publish
  extends:
    - .run_branch_from_gui
  script: "echo 'test'"

publish_docker_image_branch_manually:
  extends:
    - .run_branch_from_gui
  image: $DOCKER_IMAGE
  dependencies:
    - compile_and_test_branch_manually
  stage: publish
  script: "echo 'publish'"

I have tried also:

   rules:
    - if: '$CI_PIPELINE_SOURCE == "web"'
      when: manual
      allow_failure: false

but with no effect: still have "Pipeline cannot be run. No stages / jobs for this pipeline." when I click on "Run pipeline" button

1

1 Answers

0
votes

Without knowing your complete pipeline I would suggest you use rules, and check if $CI_PIPELINE_SOURCE is web (possible values for this variable are described here). This will run the job only if it is triggered manually.

rules:
  - if: '$CI_PIPELINE_SOURCE == "web"'