From 39b6c5e13e74bd0b94d53c0832bc7e1d46fbca92 Mon Sep 17 00:00:00 2001 From: Lars Simon Winzer Date: Sat, 14 Mar 2026 09:33:55 +0100 Subject: [PATCH] Ci: Run different jobs on push or mr --- .gitlab-ci.yml | 42 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 98d7899..018d3d6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -11,9 +11,38 @@ stages: - .gradle/ - ~/.gradle/caches/ +.on-commit: &on-commit + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + when: never + - if: '$CI_COMMIT_BRANCH' + allow_failure: true + +.on-mr: &on-mr + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + allow_failure: true # deactivate after all issues (shown by checkstyle) have been resolved + # Jobs checkstyle: - <<: *gradle-cache + <<: [*gradle-cache, *on-commit] + stage: lint + image: gradle:9.3.1-jdk25 + script: + - gradle checkstyleMain checkstyleTest + allow_failure: true + artifacts: + when: always + paths: + - build/reports/checkstyle/main.html + - build/reports/checkstyle/main.xml + - build/reports/checkstyle/test.html + - build/reports/checkstyle/test.xml + expose_as: 'Checkstyle Report' + expire_in: 1 week + +checkstyle-mr: + <<: [*gradle-cache, *on-mr] stage: lint image: gradle:9.3.1-jdk25 script: @@ -28,16 +57,16 @@ checkstyle: - build/reports/checkstyle/test.xml expose_as: 'Checkstyle Report' expire_in: 1 week - rules: - - when: manual checkstyle-report: stage: report image: python:3.14 needs: - - job: checkstyle + - job: checkstyle-mr artifacts: true optional: true + rules: + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' script: - python3 scripts/convert-checkstyle-gl-report.py artifacts: @@ -54,4 +83,7 @@ compile-check: - gradle compileTestJava needs: [] rules: - - when: manual + - if: '$CI_PIPELINE_SOURCE == "merge_request_event"' + allow_failure: false + - if: '$CI_COMMIT_BRANCH' + allow_failure: false -- 2.52.0