What I'm trying to implement is a way for programmers to run pipeline to build and deploy their branch on some server if it is needed by clicking run manually in merge request or on branch itself only after test part is passed.
The problem is that inside branch itself pipeline runs perfectly as I want it to does but on MR's i get an yaml error:
'build_publish_branch' job needs 'test' job, but 'test' is not in any previous stage
I have gitlab-ci here is the most imporant parts:
stages:
- test
- build_publish
- deploy
test:
stage: test
when: always
.build_publish_job:
stage: build_publish
needs: ['test']
build_publish_branch:
extends: .build_publish_job
rules:
- if : $CI_COMMIT_BRANCH != 'test'
when: manual
build_publish_test:
extends: .build_publish_job
rules:
- if : $CI_COMMIT_BRANCH == 'test'
.deploy_job:
stage: deploy
deploy_branch:
extends: .deploy_job
needs: ['build_publish_branch']
rules:
- if : $CI_COMMIT_BRANCH != 'test'
when: always
deploy_test:
extends: .deploy_job
needs: ['build_publish_test']
rules:
- if : $CI_COMMIT_BRANCH == 'test'
What am I missing?
Okay so solution was to just add rule for always and on merge in test job:
test:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- when: always