From 36112370e0dfa1f5961b62cb374ff3c8f3d3cda7 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 f5c636d53..8e4acbf7d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,7 +31,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" @@ -44,6 +44,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 a434c33c3aa25ad06c8b954cd2cd17b55938e1f3 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 8e4acbf7d..4bd54e703 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,7 +31,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" @@ -52,8 +52,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 80b64df7fa42e37b27ca2060ed6814d3af456280 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 4bd54e703..0a0c97b9d 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -31,7 +31,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