Skip to content
Snippets Groups Projects
Commit ab941a2c authored by Grégoire Kubler's avatar Grégoire Kubler
Browse files

Merge branch 'fix_legacy_shared_script_fix' into 'main'

Fix legacy shared script fix

See merge request !12
parents f1554d02 0919ff4f
No related branches found
No related tags found
1 merge request!12Fix legacy shared script fix
...@@ -42,31 +42,33 @@ ...@@ -42,31 +42,33 @@
fi fi
# Retrieve latest successful $DEPENDENCY_JOB from $BRANCH_TO_PULL # Retrieve latest successful $DEPENDENCY_JOB from $BRANCH_TO_PULL
- PIPELINES=$(curl -s "${API_URL}/projects/$DEPENDENCY_ID/pipelines?ref=${BRANCH_TO_PULL}&order_by=updated_at&sort=desc") - PIPELINES=$(curl -s "$API_URL/projects/$DEPENDENCY_ID/pipelines?ref=$BRANCH_TO_PULL&order_by=updated_at&sort=desc")
- JOB_ID=-1 - JOB_ID=-1
# handle case where there is no branch with the same name # handle case where there is no branch with the same name
- > - >
for i in $(seq 0 $(jq length <<< "$PIPELINES")); do for i in $(seq 0 $(($(jq length <<<$PIPELINES) - 1))); do
PIPELINE_ID=$(jq --argjson idx $i '.[$idx].id' <<< $PIPELINES) PIPELINE_ID=$(jq --argjson idx $i '.[$idx].id' <<< $PIPELINES)
JOBS=$(curl -s "${API_URL}/projects/$DEPENDENCY_ID/pipelines/$PIPELINE_ID/jobs" | jq --arg job_name "$DEPENDENCY_JOB" 'map(select((.name == $job_name) and (.status == "success")))') JOBS=$(curl -s "${API_URL}/projects/$DEPENDENCY_ID/pipelines/$PIPELINE_ID/jobs")
echo "looking for successful $DEPENDENCY_JOB in PIPELINE $PIPELINE_ID"
JOBS=$(jq --arg job_name "$DEPENDENCY_JOB" 'map(select((.name == $job_name) and (.status == "success")))' <<< $JOBS)
if [[ $(jq '. | length' <<< $JOBS) > 0 ]]; then if [[ $(jq '. | length' <<< $JOBS) > 0 ]]; then
JOB_ID=$(jq '.[0].id' <<< $JOBS) JOB_ID=$(jq '.[0].id' <<< $JOBS)
break break
fi fi
done done
- > - >
if( $JOB_ID == -1 ) ; then if [[ "$JOB_ID" == "-1" ]] ; then
echo "ERROR : no successful job \"$DEPENDENCY_JOB\" found in branch \"$BRANCH_TO_PULL\" for project \"$DEPENDENCY_NAME\"" echo "ERROR : no successful job \"$DEPENDENCY_JOB\" found in branch \"$BRANCH_TO_PULL\" for project \"$DEPENDENCY_NAME\""
else exit
echo "Successful job \"$DEPENDENCY_JOB\" found in branch \"$BRANCH_TO_PULL\" for project \"$DEPENDENCY_NAME\""
fi fi
- echo "Successful job \"$DEPENDENCY_JOB\" found in branch \"$BRANCH_TO_PULL\" for project \"$DEPENDENCY_NAME\""
- echo "curling from \"${API_URL}/projects/$DEPENDENCY_ID/jobs/$JOB_ID/artifacts\"" - echo "curling from \"${API_URL}/projects/$DEPENDENCY_ID/jobs/$JOB_ID/artifacts\""
- curl --location --output build_artifacts.zip "${API_URL}/projects/$DEPENDENCY_ID/jobs/$JOB_ID/artifacts" - curl --location --output build_artifacts.zip "${API_URL}/projects/$DEPENDENCY_ID/jobs/$JOB_ID/artifacts"
- unzip -q -o build_artifacts.zip -d . - unzip -q -o build_artifacts.zip -d .
- rm -rf build_cpp - rm -rf build_cpp
- set +x - set +x
.download_dependency_windows: .download_dependency_windows:
# Note: # Note:
# For this script to work you need to define teh following variables # For this script to work you need to define teh following variables
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment