Hello!
I have one pipeline(qa, dev, stage) for several branches. For each branch I have jobs. All work great without one thing.
When my developer does a merge request, pipeline triggers jobs for all branches. For example, he runs merge request from develop to qa branch and it triggers jobs for qa, develop, stage branch. But I want to trigger jobs only for branch where merge requests are done.
How can I fix it?
Here sample of my pipe:
workflow:
rules:
- if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH || $CI_COMMIT_BRANCH == "develop" || $CI_COMMIT_BRANCH == "qa" || $CI_COMMIT_BRANCH == "stage")
- if: ($CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
when: never
stages:
- test
- buildpush
.buildpush: &buildpush
- echo "Hello, this is build"
.deploy: &deploy
- echo "Hello, this is deploy"
Unit Tests:
stage: test
script:
- test
only:
refs:
- develop
- qa
- stage
- pushes
changes:
- src/**/*
### BUILDPUSH ###
## BUILDPUSH DEV ##
Gatewaygame build DEV:
stage: buildpush
environment: develop
script:
- export IMAGE_NAME=gatewaygame-dev
- export PROJECT_PATH=src/GatewayGame/Dockerfile
- export ENV_NAME=DEV
- *buildpush
only:
refs:
- develop
- pushes
changes:
- src/Common/**/*
- src/GatewayGame/**/*
needs:
- Unit Tests
## BUILDPUSH QA ##
Gatewaygame build QA:
stage: buildpush
environment: qa
script:
- export IMAGE_NAME=gatewaygame-qa
- export PROJECT_PATH=src/GatewayGame/Dockerfile
- export ENV_NAME=QA
- *buildpush
only:
refs:
- qa
- pushes
changes:
- src/Common/**/*
- src/GatewayGame/**/*
needs:
- Unit Tests
Gatewaygame build STAGE:
stage: buildpush
environment: stage
script:
- export IMAGE_NAME=gatewaygame-staging
- export PROJECT_PATH=src/GatewayGame/Dockerfile
- export ENV_NAME=STAGING
- *buildpush
only:
refs:
- stage
- pushes
changes:
- src/Common/**/*
- src/GatewayGame/**/*
needs:
- Unit Tests
Thanks!