Skip to content

Commit

Permalink
SONARPY-2471: Orchestrator cache should be cleaned up when using the …
Browse files Browse the repository at this point in the history
…DEV version (#2254)
  • Loading branch information
Seppli11 authored Dec 17, 2024
1 parent d53b19b commit 16c9750
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
7 changes: 5 additions & 2 deletions .cirrus.yml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ plugin_qa_task:
<<: *ONLY_SONARSOURCE_QA
eks_container:
<<: *QA_CONTAINER_DEFINITION
cpu: 3
cpu: 6
memory: 8G
env:
CIRRUS_CLONE_DEPTH: 10
Expand All @@ -178,8 +178,10 @@ plugin_qa_task:
- source cirrus-env QA
- source set_maven_build_version $BUILD_NUMBER
- cd its/plugin
- mvn verify -Dsonar.runtimeVersion=${SQ_VERSION} -Dmaven.test.redirectTestOutputToFile=false -B -e -V
- mvn verify -Dsonar.runtimeVersion=${SQ_VERSION} -Dmaven.test.redirectTestOutputToFile=false -B -e -V -Djunit.jupiter.execution.parallel.config.dynamic.factor=1
cleanup_before_cache_script: cleanup_maven_repository
cleanup_before_orchestrator_cache_script: bash .cirrus/clean-orchestrator-cache.sh


ruling_task:
depends_on:
Expand Down Expand Up @@ -225,6 +227,7 @@ pr_analysis_qa_task:
- cd its/ruling
- mvn verify -Dsonar.runtimeVersion=LATEST_RELEASE -Dmaven.test.redirectTestOutputToFile=false -B -e -V -Dtest=PythonPrAnalysisTest
cleanup_before_cache_script: cleanup_maven_repository
cleanup_before_orchestrator_cache_script: bash .cirrus/clean-orchestrator-cache.sh

promote_task:

Check warning on line 232 in .cirrus.yml

View check run for this annotation

Cirrus CI / Build Parsing Results

.cirrus.yml#L232

task "promote" depends on task "ws_scan", but their only_if conditions are different
depends_on:
Expand Down
25 changes: 25 additions & 0 deletions .cirrus/clean-orchestrator-cache.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
cd "$ORCHESTRATOR_HOME" || exit 1

# Find all sonar-application-* JAR files, sort them by version, and list them
files=$(find . -name "sonar-application-*" | sort --version-sort --field-separator=- --key=3 --reverse)

# Print the files that will be kept (the latest one)
echo "Files that won't be deleted:"
echo "$files" | head -n 1

# Get the files that will be deleted (all except the latest one)
files_to_delete=$(echo "$files" | tail -n +2)

echo ""
# Check if there are files to delete
if [ -z "$files_to_delete" ]; then
echo "No files will be deleted."
else
# Print the files that will be deleted
echo "Files that will be deleted:"
echo "$files_to_delete"

# Delete the files that will be deleted
echo "$files_to_delete" | xargs -I {} sh -c 'rm -f "{}" && rmdir "$(dirname "{}")" 2>/dev/null || true'
fi

0 comments on commit 16c9750

Please sign in to comment.