MR is not merged after job passes with specific rules
Summary
Merge request is not merged even after all pipeline pass and all approval are given, when a rule in place mimics what ci.skip would do:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_COMMIT_AUTHOR != 'project-token <email>'
Steps to reproduce
- Add a project access token with
api, read_api, read_repository, write_repositoryscopes - Create a .yml file that runs a job with rule mentioned above. The one I have is:
clear-merge-directory:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_COMMIT_AUTHOR != 'oa-remote-push <oa-remote-push@email.com>'
stage: cleanup
script:
- |
if [[ "$(ls -A ./merge/)" ]]; then
echo "clearing merge directory"
sh ./clear-merge-directory.sh
echo $CI_COMMIT_MESSAGE
fi
for this example, clear-merge-directory is this
git remote set-url origin "https://project_${CI_PROJECT_ID}_bot:$PROJECT_ACCESS_TOKEN@gitlab.com/$CI_PROJECT_PATH.git"
git config user.email "oa-remote-push@email.com"
git config user.name "oa-remote-push"
git fetch && git checkout $CI_COMMIT_REF_NAME && git pull
rm -rf ./merge/
git add .
git commit -m "[oa-remote-push] remove merge directory and its contents"
git push origin $CI_COMMIT_REF_NAME
- Create a merge request and let the pipeline pass.
- Pipeline will pass and gitlab will keep checking pipeline status indefinitely.
What is the current bug behavior?
Merge request has a pipeline that runs in two stages: merge job and clear-merge-directory job. both jobs run with rule:
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event' && $CI_COMMIT_AUTHOR != 'oa-remote-push <email>'
When a new MR is created, first job runs and passes, second job is triggered and it includes a commit created by project token oa-remtoe-push.
And a new commited is added to the work history by the project token

But then the MR remains in limbo.

What is the expected correct behavior?
Merge request is ready to merge, or auto-merged if auto-merge is enabled.
