Skip to content

Commit 838a79e

Browse files
authored
[RORDEV-1581] checking if audit artifact is already published (#1150)
1 parent 8d421df commit 838a79e

File tree

2 files changed

+31
-6
lines changed

2 files changed

+31
-6
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ target/
5353

5454
.travis/secret.pgp
5555
.java-version
56+
.sdkmanrc
5657

5758
// docker-envs
5859
builds/*
@@ -67,4 +68,4 @@ docker-envs/eck/kind-cluster/subst-ror
6768
.bloop/
6869
.bsp/
6970
.metals/
70-
.vscode/
71+
.vscode/

ci/run-pipeline.sh

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -382,18 +382,42 @@ if [[ -z $TRAVIS ]] || [[ $ROR_TASK == "release_es6xx" ]]; then
382382
release_ror_plugins "ci/supported-es-versions/es6x.txt"
383383
fi
384384

385-
if [[ $ROR_TASK == "publish_maven_artifacts" ]] && [[ $TRAVIS_BRANCH == "master" ]]; then
385+
check_maven_artifacts_exist() {
386+
local CURRENT_VERSION="$1"
387+
388+
local ARTIFACT_URL="https://oss.sonatype.org/service/local/repositories/releases/content/tech/beshu/ror/audit_3/$CURRENT_VERSION/"
389+
echo ">>> Checking if Maven artifacts already exist at: $ARTIFACT_URL"
390+
391+
local MVN_STATUS=$(curl -L --write-out '%{http_code}' --silent --output /dev/null "$ARTIFACT_URL" || echo "000")
392+
393+
if [[ $MVN_STATUS == "404" ]]; then
394+
echo ">>> Maven artifacts not found"
395+
return 1
396+
elif [[ $MVN_STATUS == "200" ]]; then
397+
echo ">>> Maven artifacts for version $CURRENT_VERSION already exist."
398+
return 0
399+
else
400+
echo ">>> ERROR: Unexpected HTTP status $MVN_STATUS when checking Maven repository"
401+
echo ">>> Cannot determine if artifacts exist, failing to avoid potential issues"
402+
exit 1
403+
fi
404+
}
386405

406+
if [[ $ROR_TASK == "publish_maven_artifacts" ]] && [[ $TRAVIS_BRANCH == "master" ]]; then
387407
# .travis/secret.pgp is downloaded via Azure secret files, see azure-pipelines.yml
388-
389408
CURRENT_PLUGIN_VER=$(awk -F= '$1=="pluginVersion" {print $2}' gradle.properties)
390409
PUBLISHED_PLUGIN_VER=$(awk -F= '$1=="publishedPluginVersion" {print $2}' gradle.properties)
391410

392411
if [[ $CURRENT_PLUGIN_VER == $PUBLISHED_PLUGIN_VER ]]; then
393-
echo ">>> Publishing audit module artifacts to sonatype repo"
394-
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
412+
if check_maven_artifacts_exist "$CURRENT_PLUGIN_VER"; then
413+
echo ">>> Skipping publishing audit module artifacts"
414+
else
415+
echo ">>> Publishing audit module artifacts to sonatype repo"
416+
./gradlew publishToSonatype closeAndReleaseSonatypeStagingRepository
417+
fi
395418
else
396-
echo ">>> Skipping publishing audit module artifacts"
419+
echo ">>> Version mismatch: current=$CURRENT_PLUGIN_VER, published=$PUBLISHED_PLUGIN_VER"
420+
echo ">>> Skipping publishing audit module artifacts."
397421
fi
398422
fi
399423

0 commit comments

Comments
 (0)