1

I have a set up a pipeline .gitlab-ci.yml where build and deploy to dev works fine. The rule is to run a pipeline for QA after the merge request from develop to QA.

When I create a merge request it runs a pipeline only for this stage ,it is not running build stage again. Can you please help me how to make build run for every stage.

stages:
  - build
  - deploy dev         
  - deploy release    
  
build: 
  stage: build 
  script:
    -  build  

deploy dev: 
  stage: deploy dev 
  environment: DEV
  only:
    - develop   
    
deploy release: 
  stage: deploy release 
  dependencies:
    - build 
  environment: QA
  rules:
    - if:  $CI_PIPELINE_SOURCE == "merge_request_event"
    - if:  $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME == "develop"
Mani
  • 721
  • 3
  • 10
  • 24
  • Do you want to deploy from your merge-request or from your qa pipeline? And it's hard to say why the build stage is not running for your qa pipeline without seeing the full pipeline. – danielnelz Apr 20 '21 at 11:13
  • @danielnelz added the full pipeline. When we merge from develop to release .i want the build and deploy release stage should trigger and deploy release should trigger only on this merge request – Mani Apr 20 '21 at 11:57

1 Answers1

0

You can add a rule to your build job that it should run on merge-requests and if the branch which is commited on has the name develop.

build: 
  stage: build 
  script:
    -  build
  rules:
    - if: '$CI_COMMIT_BRANCH == "develop" || $CI_PIPELINE_SOURCE == "merge_request_event"'
danielnelz
  • 3,794
  • 4
  • 25
  • 35
  • No I mean the following When we commit to DEV Build--> Deploy DEV stage should run When we merge from DEV-> QA branch then BUILD-> DEPLOY QA stage – Mani Apr 20 '21 at 12:31