From e097e0a54463739bca1ee96860e67d884ad62723 Mon Sep 17 00:00:00 2001 From: Guilhem Bonnefille Date: Thu, 12 Aug 2021 08:07:59 +0000 Subject: [PATCH 1/3] Avoid breaking pipeline for unconfigured SonarQube As quality should be checked, a failing stage is introduced to keep integrator aware. --- .gitlab-ci.yml | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6d43228d7..4263a33c6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,7 +27,7 @@ verify: stage: verify script: - mvn $MAVEN_CLI_OPTS verify site - - mvn $MAVEN_CLI_OPTS sonar:sonar + - test -n "$SONAR_TOKEN" -a -n "$SONAR_PROJECT_KEY" -a "$SONAR_PROJECT_NAME" && mvn $MAVEN_CLI_OPTS sonar:sonar -Dsonar.login=${SONAR_TOKEN} -Dsonar.branch.name=${CI_COMMIT_REF_NAME} -Dsonar.projectKey="$SONAR_PROJECT_KEY" @@ -40,6 +40,17 @@ verify: junit: - target/surefire-reports/*.xml +verify:warning: + stage: verify + script: + - echo "Please, configure SonarQube!" + - exit 1 + allow_failure: true + rules: + - if: $SONAR_TOKEN == null + - if: $SONAR_PROJECT_KEY == null + - if: $SONAR_PROJECT_NAME == null + # Convert and import in GitLab coverage data. # The information is then available directly in merge-request view. # Cf. https://docs.gitlab.com/ee/user/project/merge_requests/test_coverage_visualization.html -- GitLab From fab4e1943be3eb6833986439f3c4f3f48e4f9092 Mon Sep 17 00:00:00 2001 From: Guilhem Bonnefille Date: Thu, 12 Aug 2021 08:22:16 +0000 Subject: [PATCH 2/3] Remove checks on SONAR_PROJECT_KEY and SONAR_PROJECT_NAME These variables are necessarily set due to initial declarations at the top of gitlab-ci.yml. --- .gitlab-ci.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4263a33c6..b9b4e35b8 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,7 +27,7 @@ verify: stage: verify script: - mvn $MAVEN_CLI_OPTS verify site - - test -n "$SONAR_TOKEN" -a -n "$SONAR_PROJECT_KEY" -a "$SONAR_PROJECT_NAME" && mvn $MAVEN_CLI_OPTS sonar:sonar + - test -n "$SONAR_TOKEN" && mvn $MAVEN_CLI_OPTS sonar:sonar -Dsonar.login=${SONAR_TOKEN} -Dsonar.branch.name=${CI_COMMIT_REF_NAME} -Dsonar.projectKey="$SONAR_PROJECT_KEY" @@ -48,8 +48,6 @@ verify:warning: allow_failure: true rules: - if: $SONAR_TOKEN == null - - if: $SONAR_PROJECT_KEY == null - - if: $SONAR_PROJECT_NAME == null # Convert and import in GitLab coverage data. # The information is then available directly in merge-request view. -- GitLab From 25e2a995ef10568d9843e1415201ae6cfc99b162 Mon Sep 17 00:00:00 2001 From: Guilhem Bonnefille Date: Thu, 12 Aug 2021 09:01:51 +0000 Subject: [PATCH 3/3] Invert test logic to avoid failing job --- .gitlab-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index b9b4e35b8..2136884d6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -27,7 +27,7 @@ verify: stage: verify script: - mvn $MAVEN_CLI_OPTS verify site - - test -n "$SONAR_TOKEN" && mvn $MAVEN_CLI_OPTS sonar:sonar + - test -z "$SONAR_TOKEN" || mvn $MAVEN_CLI_OPTS sonar:sonar -Dsonar.login=${SONAR_TOKEN} -Dsonar.branch.name=${CI_COMMIT_REF_NAME} -Dsonar.projectKey="$SONAR_PROJECT_KEY" -- GitLab