MR Job fails when no merge request found
📚 Summary
If there is no merge request on the branch, the job will fail with an output of No commit found with range: 'None'
The logic in .gitlab-ci.yml needs to be fixed.
- MR_TITLE=$($ROOT_DIR/conventional_commits/scripts/commit.py --token "$MR_ACCESS_TOKEN" --project $PROJECT_ID --title --branch $CI_COMMIT_BRANCH)
- echo "[DEBUG] MR_TITLE[$MR_TITLE]"
- if [ "0$MR_TITLE" == "0" ]; then echo "DEBUG No Merge Request found"; fi
- if [ "0$MR_TITLE" != "0" ]; then cz_exit=0 && cz check --message "$MR_TITLE" > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/$CI_JOB_NAME/cz_output.log" 2>&1 || cz_exit=$?; fi
- if [ "0$MR_TITLE" != "0" ]; then . $ROOT_DIR/conventional_commits/scripts/cz_junit.sh > "$CI_PROJECT_DIR/artifacts/$CI_JOB_STAGE/tests/$CI_JOB_NAME-cz.junit.xml"; fi
Don't do above suggestion as there should always be an output from commit.py
🔗 References
Edited by Jon