From 85bf47a33aa69f3141ea442248b6c2b2c6f07774 Mon Sep 17 00:00:00 2001 From: 7PH Date: Tue, 18 Jun 2024 17:04:02 +0200 Subject: [PATCH] SONAR-22263 Use 'rules:' instead of 'only:' in GitLab tutorials --- .../GitLabCITutorial-it.tsx.snap | 80 +++++++++---------- .../gitlabci/commands/PipeCommand.tsx | 20 ++--- 2 files changed, 50 insertions(+), 50 deletions(-) diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-it.tsx.snap b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-it.tsx.snap index 673c2eee458..905163f387c 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-it.tsx.snap +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/__tests__/__snapshots__/GitLabCITutorial-it.tsx.snap @@ -24,22 +24,22 @@ sonarqube-check: - "dotnet build" - "dotnet sonarscanner end /d:sonar.token=\\"$SONAR_TOKEN\\"" allow_failure: true - only: - - merge_requests - - master - - main - - develop + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_COMMIT_BRANCH == 'master' + - if: $CI_COMMIT_BRANCH == 'main' + - if: $CI_COMMIT_BRANCH == 'develop' sonarqube-vulnerability-report: stage: sonarqube-vulnerability-report script: - 'curl -u "\${SONAR_TOKEN}:" "\${SONAR_HOST_URL}/api/issues/gitlab_sast_export?projectKey=my-project&branch=\${CI_COMMIT_BRANCH}&pullRequest=\${CI_MERGE_REQUEST_IID}" -o gl-sast-sonar-report.json' allow_failure: true - only: - - merge_requests - - master - - main - - develop + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_COMMIT_BRANCH == 'master' + - if: $CI_COMMIT_BRANCH == 'main' + - if: $CI_COMMIT_BRANCH == 'develop' artifacts: expire_in: 1 day reports: @@ -66,22 +66,22 @@ sonarqube-check: - .sonar/cache script: gradle sonar allow_failure: true - only: - - merge_requests - - master - - main - - develop + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_COMMIT_BRANCH == 'master' + - if: $CI_COMMIT_BRANCH == 'main' + - if: $CI_COMMIT_BRANCH == 'develop' sonarqube-vulnerability-report: stage: sonarqube-vulnerability-report script: - 'curl -u "\${SONAR_TOKEN}:" "\${SONAR_HOST_URL}/api/issues/gitlab_sast_export?projectKey=my-project&branch=\${CI_COMMIT_BRANCH}&pullRequest=\${CI_MERGE_REQUEST_IID}" -o gl-sast-sonar-report.json' allow_failure: true - only: - - merge_requests - - master - - main - - develop + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_COMMIT_BRANCH == 'master' + - if: $CI_COMMIT_BRANCH == 'main' + - if: $CI_COMMIT_BRANCH == 'develop' artifacts: expire_in: 1 day reports: @@ -137,22 +137,22 @@ sonarqube-check: script: - mvn verify sonar:sonar allow_failure: true - only: - - merge_requests - - master - - main - - develop + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_COMMIT_BRANCH == 'master' + - if: $CI_COMMIT_BRANCH == 'main' + - if: $CI_COMMIT_BRANCH == 'develop' sonarqube-vulnerability-report: stage: sonarqube-vulnerability-report script: - 'curl -u "\${SONAR_TOKEN}:" "\${SONAR_HOST_URL}/api/issues/gitlab_sast_export?projectKey=my-project&branch=\${CI_COMMIT_BRANCH}&pullRequest=\${CI_MERGE_REQUEST_IID}" -o gl-sast-sonar-report.json' allow_failure: true - only: - - merge_requests - - master - - main - - develop + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_COMMIT_BRANCH == 'master' + - if: $CI_COMMIT_BRANCH == 'main' + - if: $CI_COMMIT_BRANCH == 'develop' artifacts: expire_in: 1 day reports: @@ -190,22 +190,22 @@ sonarqube-check: script: - sonar-scanner allow_failure: true - only: - - merge_requests - - master - - main - - develop + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_COMMIT_BRANCH == 'master' + - if: $CI_COMMIT_BRANCH == 'main' + - if: $CI_COMMIT_BRANCH == 'develop' sonarqube-vulnerability-report: stage: sonarqube-vulnerability-report script: - 'curl -u "\${SONAR_TOKEN}:" "\${SONAR_HOST_URL}/api/issues/gitlab_sast_export?projectKey=my-project&branch=\${CI_COMMIT_BRANCH}&pullRequest=\${CI_MERGE_REQUEST_IID}" -o gl-sast-sonar-report.json' allow_failure: true - only: - - merge_requests - - master - - main - - develop + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_COMMIT_BRANCH == 'master' + - if: $CI_COMMIT_BRANCH == 'main' + - if: $CI_COMMIT_BRANCH == 'develop' artifacts: expire_in: 1 day reports: diff --git a/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/PipeCommand.tsx b/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/PipeCommand.tsx index 5e092e4b2ce..907d1988476 100644 --- a/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/PipeCommand.tsx +++ b/server/sonar-web/src/main/js/components/tutorials/gitlabci/commands/PipeCommand.tsx @@ -77,22 +77,22 @@ sonarqube-check: - .sonar/cache script: ${script(projectKey)} allow_failure: true - only: - - merge_requests - - master - - main - - develop + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_COMMIT_BRANCH == 'master' + - if: $CI_COMMIT_BRANCH == 'main' + - if: $CI_COMMIT_BRANCH == 'develop' sonarqube-vulnerability-report: stage: sonarqube-vulnerability-report script: - 'curl -u "\${SONAR_TOKEN}:" "\${SONAR_HOST_URL}/api/issues/gitlab_sast_export?projectKey=${projectKey}&branch=\${CI_COMMIT_BRANCH}&pullRequest=\${CI_MERGE_REQUEST_IID}" -o gl-sast-sonar-report.json' allow_failure: true - only: - - merge_requests - - master - - main - - develop + rules: + - if: $CI_PIPELINE_SOURCE == 'merge_request_event' + - if: $CI_COMMIT_BRANCH == 'master' + - if: $CI_COMMIT_BRANCH == 'main' + - if: $CI_COMMIT_BRANCH == 'develop' artifacts: expire_in: 1 day reports: -- 2.39.5