From eabc8948e2fd0a2577c7a0090bfef21d747b2601 Mon Sep 17 00:00:00 2001 From: Ilia Kebets <104737176+ilia-kebets-sonarsource@users.noreply.github.com> Date: Mon, 30 Oct 2023 16:10:45 +0100 Subject: [PATCH] Fix CI by using generic script `regular_mvn_build_deploy_analyze` again (#4328) --- .cirrus.yml | 14 ++++++++----- .cirrus/analyze.bash | 15 -------------- .cirrus/deploy.bash | 6 ------ .cirrus/prepare_deploy_analyze.bash | 32 ----------------------------- 4 files changed, 9 insertions(+), 58 deletions(-) delete mode 100755 .cirrus/analyze.bash delete mode 100755 .cirrus/deploy.bash delete mode 100755 .cirrus/prepare_deploy_analyze.bash diff --git a/.cirrus.yml b/.cirrus.yml index ec7b34d310e..d597a56fa01 100644 --- a/.cirrus.yml +++ b/.cirrus.yml @@ -104,14 +104,17 @@ build_task: #sign artifacts SIGN_KEY: VAULT[development/kv/data/sign data.key] PGP_PASSPHRASE: VAULT[development/kv/data/sign data.passphrase] + SONAR_TOKEN: VAULT[development/kv/data/next data.token] + SONAR_HOST_URL: https://next.sonarqube.com/sonarqube + ARTIFACTORY_DEPLOY_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer access_token] <<: *MAVEN_CACHE <<: *RUNTIME_CACHE build_and_deploy_script: - source cirrus-env BUILD + - jfrog config add repox --url $ARTIFACTORY_URL --access-token $ARTIFACTORY_DEPLOY_ACCESS_TOKEN - npm config set registry "${ARTIFACTORY_URL}/api/npm/npm" - npm run build - - ./.cirrus/prepare_deploy_analyze.bash - - ./.cirrus/deploy.bash + - regular_mvn_build_deploy_analyze -Dmaven.test.skip=true -Dmaven.install.skip=true -Dsonar.skip=true cleanup_before_cache_script: cleanup_maven_repository analyze_task: @@ -128,6 +131,7 @@ analyze_task: # analysis on next SONAR_TOKEN: VAULT[development/kv/data/next data.token] SONAR_HOST_URL: https://next.sonarqube.com/sonarqube + ARTIFACTORY_DEPLOY_ACCESS_TOKEN: VAULT[development/artifactory/token/${CIRRUS_REPO_OWNER}-${CIRRUS_REPO_NAME}-qa-deployer access_token] <<: *MAVEN_CACHE <<: *RUNTIME_CACHE sonar_cache: @@ -136,11 +140,11 @@ analyze_task: - echo ${CIRRUS_OS} - curl --silent ${SONAR_HOST_URL}/deploy/plugins/index.txt | sort build_and_analyze_script: - - source cirrus-env CI + - source cirrus-env QA + - jfrog config add repox --url $ARTIFACTORY_URL --access-token $ARTIFACTORY_DEPLOY_ACCESS_TOKEN - npm config set registry "${ARTIFACTORY_URL}/api/npm/npm" - npm run build - - ./.cirrus/prepare_deploy_analyze.bash - - ./.cirrus/analyze.bash + - PULL_REQUEST_SHA=$GIT_SHA1 regular_mvn_build_deploy_analyze -P-deploy-sonarsource,-release,-sign -Dcommercial -Dmaven.shade.skip=true -Dmaven.test.skip=true -Dmaven.install.skip=true -Dmaven.deploy.skip=true -Dsonar.coverage.jacoco.xmlReportPaths=$CIRRUS_WORKING_DIR/report-aggregate/target/site/jacoco-aggregate/jacoco.xml build_win_task: depends_on: diff --git a/.cirrus/analyze.bash b/.cirrus/analyze.bash deleted file mode 100755 index c4739bd3698..00000000000 --- a/.cirrus/analyze.bash +++ /dev/null @@ -1,15 +0,0 @@ -#!/bin/bash - -# inspired by https://github.com/SonarSource/re-ci-images/blob/b9f43ffec926c0828a279aefc5a94cb5060bfee5/docker/bin/src/regular_mvn_build_deploy_analyze#L51-L61 - -mvn verify sonar:sonar \ - -Pcoverage \ - -Dmaven.test.redirectTestOutputToFile=false \ - -Dsonar.host.url="$SONAR_HOST_URL" \ - -Dsonar.token="$SONAR_TOKEN" \ - -Dsonar.projectVersion="$CURRENT_VERSION" \ - -Dsonar.analysis.buildNumber="$BUILD_NUMBER" \ - -Dsonar.analysis.pipeline="$PIPELINE_ID" \ - -Dsonar.analysis.sha1="$GIT_SHA1" \ - -Dsonar.analysis.repository="$GITHUB_REPO" \ - -B -e -V "$@" diff --git a/.cirrus/deploy.bash b/.cirrus/deploy.bash deleted file mode 100755 index cff780fc423..00000000000 --- a/.cirrus/deploy.bash +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/bash - -# inspired from https://github.com/SonarSource/re-ci-images/blob/1f74074e7162373b2139a514a3b4013d85a29d43/docker/bin/src/regular_mvn_build_deploy_analyze#L51-L61 - -# we've already run the tests during the build phase -mvn deploy -DskipTests -Pdeploy-sonarsource,release,sign -B -e -V "$@" diff --git a/.cirrus/prepare_deploy_analyze.bash b/.cirrus/prepare_deploy_analyze.bash deleted file mode 100755 index 71302fdea28..00000000000 --- a/.cirrus/prepare_deploy_analyze.bash +++ /dev/null @@ -1,32 +0,0 @@ -#!/bin/bash - -# taken from includes/version_util -# https://github.com/SonarSource/re-ci-images/blob/b9f43ffec926c0828a279aefc5a94cb5060bfee5/docker/bin/src/includes/version_util#L15-L22 - -# Verify that the version declared in pom.xml or in gradle.properties -# use the following pattern: x.x.x.x (...) and warn if not. -# Args: -# $1 The version string to check -function check_version_format(){ - local version=$1 - local extracted_points="${version//[^.]}" - local point_count=${#extracted_points} - if [[ "$point_count" != 3 ]]; then - echo "WARN: This version $version does not match the standardized format used commonly across the organization: '...'." - fi -} - -# taken from regular_mvn_build_deploy_analyze -# https://github.com/SonarSource/re-ci-images/blob/b9f43ffec926c0828a279aefc5a94cb5060bfee5/docker/bin/src/regular_mvn_build_deploy_analyze#L41-L49 - -# Analyze with SNAPSHOT version as long as SQ does not correctly handle -# purge of release data -export CURRENT_VERSION=$(maven_expression "project.version") - -. set_maven_build_version "$BUILD_NUMBER" - -export MAVEN_OPTS="-Xmx1536m -Xms128m" - -check_version_format "$PROJECT_VERSION" - -