I'm using GitLab CI/CD (EDIT: v10.2.2).
I've got 2 branches in my project: devel
and testing
Both are protected.
devel
is the default branch.
The workflow is: I push on devel
, then I merge devel
into testing
through a merge request.
Here is my .gitlab-ci.yml
v1:
docker_build:
stage: build
only:
- devel
script:
- docker build -t gitlab.mydomain.com:4567/myproject/app:debug1 .
- docker login -u="$DOCKER_LOGIN" -p="$DOCKER_PWD" gitlab.mydomain.com:4567
- docker push gitlab.mydomain.com:4567/myproject/app:debug1
When I push a modification on devel
, the script is run and the build is made. Perfect.
Now same thing with branch testing
, here is my .gitlab-ci.yml
v2:
docker_build:
stage: build
only:
- testing
script:
- docker build -t gitlab.mydomain.com:4567/myproject/app:debug2 .
- docker login -u="$DOCKER_LOGIN" -p="$DOCKER_PWD" gitlab.mydomain.com:4567
- docker push gitlab.mydomain.com:4567/myproject/app:debug2
When I push a modification directly on testing
, the same thing happens using the testing
branch. But here the pipeline on testing
(and on testing
only, so only once) is also triggered when I push on devel
, then merge on testing
, which is perfect.
Now .gitlab-ci.yml
v3, which is nothing else than a concatenation of the two previous versions:
docker_build:
stage: build
only:
- devel
script:
- docker build -t gitlab.mydomain.com:4567/myproject/app:debug1 .
- docker login -u="$DOCKER_LOGIN" -p="$DOCKER_PWD" gitlab.mydomain.com:4567
- docker push gitlab.mydomain.com:4567/myproject/app:debug1
docker_build:
stage: build
only:
- testing
script:
- docker build -t gitlab.mydomain.com:4567/myproject/app:debug2 .
- docker login -u="$DOCKER_LOGIN" -p="$DOCKER_PWD" gitlab.mydomain.com:4567
- docker push gitlab.mydomain.com:4567/myproject/app:debug2
My expectation was: when I push on devel
, then create/accept a merge request from devel
to testing
, the devel
pipeline should run right after my push, then the testing
pipeline should run right after my merge request acceptance.
Instead here is what's happening: only the devel
pipeline is triggered after the push. The testing
pipeline will never be triggered after my merge request.
I assume I'm missing something about how GitLab works but I can't figure out what despite my researches.
Any help will be greatly appreciated. Thank you very much.
https://docs.gitlab.com/ee/ci/jobs/ states:
Each job must have a unique name, ...
You have two jobs with the same name docker_build
. Just give them a different name.