Commit 78c5a09d authored by Grégoire Kubler's avatar Grégoire Kubler
Browse files

chore : generalized DEP_API_URL call in ubuntu slect jobs

parent 1482934a
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -141,19 +141,19 @@
        # Retrieve latest successful $DEPENDENCY_JOB from $BRANCH_TO_PULL (including MR pipelines)
        # and sort them from newest to oldest
        echo "Retrieving pipelines from $BRANCH_TO_PULL"
        echo "Regular pipeline curled from \"$API_URL/projects/$DEP_ID/pipelines?ref=${BRANCH_TO_PULL}\""
        PIPELINES=$(curl -s "$API_URL/projects/$DEP_ID/pipelines?ref=${BRANCH_TO_PULL}")
        echo "Regular pipeline curled from \"$DEP_API_URL/pipelines?ref=${BRANCH_TO_PULL}\""
        PIPELINES=$(curl -s "$DEP_API_URL/pipelines?ref=${BRANCH_TO_PULL}")
        if [[ -z "$PIPELINES" ]]; then
        	echo "Failed to retrieve any pipeline, ensure there is a pipeline with ref $BRANCH_TO_PULL in $DEP_NAME"
        	exit 1
        fi
        echo "Found $(jq length <<<$PIPELINES) regular pipelines with $BRANCH_TO_PULL as ref."

        echo "Retrieve first affiliated MR by curling \"$API_URL/projects/$DEP_ID/merge_requests?source_branch=$BRANCH_TO_PULL&state=opened\""
        MR_ID=$(curl -s "$API_URL/projects/$DEP_ID/merge_requests?source_branch=$BRANCH_TO_PULL&state=opened" | jq '.[0].iid')
        echo "Retrieve first affiliated MR by curling \"$DEP_API_URL/merge_requests?source_branch=$BRANCH_TO_PULL&state=opened\""
        MR_ID=$(curl -s "$DEP_API_URL/merge_requests?source_branch=$BRANCH_TO_PULL&state=opened" | jq '.[0].iid')
        if [[ $MR_ID != null ]]; then
        	echo "MR pipeline curled from \"$API_URL/projects/$DEP_ID/merge_requests/$MR_ID/pipelines\""
        	MR_PIPELINES=$(curl -s "$API_URL/projects/$DEP_ID/merge_requests/$MR_ID/pipelines")
        	echo "MR pipeline curled from \"$DEP_API_URL/merge_requests/$MR_ID/pipelines\""
        	MR_PIPELINES=$(curl -s "$DEP_API_URL/merge_requests/$MR_ID/pipelines")
        	echo "Found $(jq length <<<$MR_PIPELINES) Merge Request pipelines with $BRANCH_TO_PULL as source_branch."
        else
        	echo "No merge request with source_branch = \"$BRANCH_TO_PULL\" found."
@@ -188,7 +188,7 @@
        for i in $(seq 0 $(($(jq length <<<$PIPELINES) - 1))); do
        	PIPELINE_ID=$(jq --argjson idx $i '.[$idx].id' <<<$PIPELINES)
        	echo "Current pipeline ID : $PIPELINE_ID"
        	echo "Retrieving jobs of curr pipeline from : \"$API_URL/projects/$DEP_ID/pipelines/$PIPELINE_ID/jobs\""
        	echo "Retrieving jobs of curr pipeline from : \"$DEP_API_URL/pipelines/$PIPELINE_ID/jobs\""
        	JOBS=$(curl -s "$DEP_API_URL/pipelines/$PIPELINE_ID/jobs")
        	if [[ $(jq -r '.message' <<<$JOBS) == "404 Not found" ]]; then
        		echo "WARNING: NO JOBS FOUND FOR PIPELINE $PIPELINE_ID OF PROJECT $DEP_NAME."