Skip to content

Commit abb3a35

Browse files
Add dependency on Maven Central deployment to OCI publish jobs (#9204)
* Add dependency to OCI publish jobs * Override new publishing-gate job * Change stage order because publishing-gate depends on deploy_to_maven_central * Add verify_maven_central_deployment job * Test verify_maven_central_deployment job by temporarily removing dependency * Change to registry.ddbuild image * Test failing version * Clean * Change image for verify_maven_central_deployment job * Fix verify_maven_central_deployment script * Remove publishing-gate rules * Test verify job * Add manual trigger * Fix verify script * Add test-job to see what happens when verify job fails * Clean test code * Change retry rate * Try test-job again * Clean again * Create a separate job to skip the verify maven job --------- Co-authored-by: Laplie Anderson <[email protected]>
1 parent 0f3ab90 commit abb3a35

File tree

1 file changed

+82
-1
lines changed

1 file changed

+82
-1
lines changed

.gitlab-ci.yml

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ include:
77

88
stages:
99
- build
10-
- shared-pipeline
1110
- publish
11+
- shared-pipeline
1212
- benchmarks
1313
- macrobenchmarks
1414
- tests
@@ -880,6 +880,87 @@ requirements_json_test:
880880
package-oci:
881881
needs: [ build ]
882882

883+
override_verify_maven_central:
884+
image: registry.ddbuild.io/images/base/gbi-ubuntu_2204:release
885+
stage: publish
886+
needs: [ ]
887+
rules:
888+
- if: '$POPULATE_CACHE'
889+
when: never
890+
- when: manual
891+
allow_failure: true
892+
script:
893+
- touch OVERRIDE_MAVEN_VERIFY
894+
cache: # Cache is used to signal between the override_verify_maven_central and verify_maven_central_deployment jobs
895+
- key: $CI_PIPELINE_ID-OVERRIDE_SIGNAL
896+
paths:
897+
- OVERRIDE_MAVEN_VERIFY
898+
policy: push
899+
unprotect: true
900+
901+
# Verify Maven Central deployment is publicly available before publishing OCI images
902+
verify_maven_central_deployment:
903+
image: registry.ddbuild.io/images/base/gbi-ubuntu_2204:release
904+
stage: publish
905+
needs: [ deploy_to_maven_central ]
906+
rules:
907+
- if: '$POPULATE_CACHE'
908+
when: never
909+
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
910+
when: on_success
911+
- when: manual
912+
allow_failure: true
913+
cache: # Cache is used to signal between the override_verify_maven_central and verify_maven_central_deployment jobs
914+
- key: $CI_PIPELINE_ID-OVERRIDE_SIGNAL
915+
paths:
916+
- OVERRIDE_MAVEN_VERIFY
917+
policy: pull
918+
unprotect: true
919+
script:
920+
- if [ -f OVERRIDE_MAVEN_VERIFY ]; then echo "SKIPPING MAVEN VERIFICATION"; exit 0; fi
921+
- |
922+
export VERSION=${CI_COMMIT_TAG##v}
923+
ARTIFACT_URLS=(
924+
"https://repo1.maven.org/maven2/com/datadoghq/dd-java-agent/${VERSION}/dd-java-agent-${VERSION}.jar"
925+
"https://repo1.maven.org/maven2/com/datadoghq/dd-trace-api/${VERSION}/dd-trace-api-${VERSION}.jar"
926+
"https://repo1.maven.org/maven2/com/datadoghq/dd-trace-ot/${VERSION}/dd-trace-ot-${VERSION}.jar"
927+
)
928+
# Wait 5 mins initially, then try 5 times with a minute delay between each retry to see if the release artifacts are available
929+
sleep 300
930+
TRY=0
931+
MAX_TRIES=5
932+
DELAY=60
933+
while [ $TRY -lt $MAX_TRIES ]; do
934+
ARTIFACTS_AVAILABLE=true
935+
for URL in "${ARTIFACT_URLS[@]}"; do
936+
if ! curl --location --fail --silent --show-error -I "$URL"; then
937+
ARTIFACTS_AVAILABLE=false
938+
break
939+
fi
940+
done
941+
if [ "$ARTIFACTS_AVAILABLE" = true ]; then
942+
break
943+
fi
944+
TRY=$((TRY + 1))
945+
if [ $TRY -eq $MAX_TRIES ]; then
946+
echo "The release was not available after 10 mins. Manually re-run the job to try again."
947+
exit 1
948+
fi
949+
sleep $DELAY
950+
done
951+
952+
publishing-gate:
953+
needs:
954+
- job: verify_maven_central_deployment
955+
optional: true
956+
rules:
957+
- if: '$POPULATE_CACHE'
958+
when: never
959+
- if: '$CI_COMMIT_TAG =~ /^v[0-9]+\.[0-9]+\.[0-9]+$/'
960+
when: on_success
961+
- when: manual
962+
allow_failure: true
963+
883964
configure_system_tests:
884965
variables:
885966
SYSTEM_TESTS_SCENARIOS_GROUPS: "simple_onboarding,simple_onboarding_profiling,simple_onboarding_appsec,docker-ssi,lib-injection"

0 commit comments

Comments
 (0)