Hello there,
We do have a pipeline with 3 stages: Verify → Build → Deploy.
- Verify should be run for all commits (and merge-requests)
- Build is automatic for the main branch and manual for others
- Deploy is automatic for the main branch and needs the Build stage
Our issue is that we have pipelines now, the expected one and a “detached” one.
What does that means, can we get rid of that ?
Here is the relevant part of our .gitlab-ci.yml
file:
verify:webapi:
stage: verify
...
rules:
- changes:
- src/**/*
when: on_success
build:webapi_docker_file:
stage: build
needs:
- verify:webapi
...
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: $CI_COMMIT_BRANCH == $MAIN_BRANCH
changes:
- src/**/*
when: on_success
deploy:webapi_docker_image:
stage: deploy
needs:
- build:webapi_docker_file
...
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: $CI_COMMIT_BRANCH == $MAIN_BRANCH
changes:
- src/**/*
when: on_success
build:webapi_docker_feature_file:
stage: build
needs:
- verify:webapi
...
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: $CI_COMMIT_BRANCH != $MAIN_BRANCH
changes:
- src/**/*
when: manual
deploy:webapi_docker_feature_image:
stage: deploy
needs:
- build:webapi_docker_feature_file
...
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: never
- if: $CI_COMMIT_BRANCH != $MAIN_BRANCH
changes:
- src/**/*
when: on_success
deploy:webapi_on_dev:
stage: deploy
needs:
# That's normal. We deploy the "sources", docker image is for another use
- verify:webapi
...
rules:
- if: '$CI_PIPELINE_SOURCE == "schedule"'
when: never
- if: $CI_COMMIT_BRANCH == $MAIN_BRANCH
changes:
- src/**/*
when: on_success
environment:
name: development
...