diff --git a/.gitlab/ci/download/select_jobs.gitlab-ci.yml b/.gitlab/ci/download/select_jobs.gitlab-ci.yml index a86679a7e05d75c0c177f5e190ab1956a66eac1a..e8cd8ba8f5b7b1f093a915574be739db1daf8720 100644 --- a/.gitlab/ci/download/select_jobs.gitlab-ci.yml +++ b/.gitlab/ci/download/select_jobs.gitlab-ci.yml @@ -101,14 +101,14 @@ 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 "Found $(jq length <<<$PIPELINES) regular pipelines." + 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\"" - MR_ID=$(curl -s "$API_URL/projects/$DEP_ID/merge_requests?source_branch=$BRANCH_TO_PULL" | jq '.[0].iid') + 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') 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 "Found $(jq length <<<$MR_PIPELINES) Merge Request 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." MR_PIPELINES="[]" @@ -316,12 +316,12 @@ Write-Host "****************************************************************************************************************************" Write-Host "Retrieving regular pipelines from $API_URL/projects/$DEP_ID/pipelines?ref=$BRANCH_TO_PULL" $PIPELINES=$(Invoke-RestMethod -Uri "$API_URL/projects/$DEP_ID/pipelines?ref=$BRANCH_TO_PULL" -Method Get) - Write-Host "Found $($PIPELINES.Count) pipelines linked with $BRANCH_TO_PULL as ref." - Write-Host "Retrieving MR pipelines from $API_URL/projects/$DEP_ID/merge_requests?source_branch=$BRANCH_TO_PULL" - $MR_ID=(Invoke-RestMethod -Uri "$API_URL/projects/$DEP_ID/merge_requests?source_branch=$BRANCH_TO_PULL" -Method Get) - Write-Host "Found $($MR_ID.Count) MR with $BRANCH_TO_PULL as source branch." + Write-Host "Found $($PIPELINES.Count) pipelines with $BRANCH_TO_PULL as ref." + Write-Host "Retrieving Merge requests pipelines from $API_URL/projects/$DEP_ID/merge_requests?source_branch=$BRANCH_TO_PULL&state=opened" + $MR_ID=(Invoke-RestMethod -Uri "$API_URL/projects/$DEP_ID/merge_requests?source_branch=$BRANCH_TO_PULL&state=opened" -Method Get) + Write-Host "Found $($MR_ID.Count) opened MR with $BRANCH_TO_PULL as source branch." if ( $MR_ID.Count -ne 0 ){ - $MR_PIPELINES=(Invoke-RestMethod -Uri "$API_URL/projects/$DEP_ID/merge_requests/$MR_ID/pipelines" -Method Get) + $MR_PIPELINES=(Invoke-RestMethod -Uri "$API_URL/projects/$DEP_ID/merge_requests/$($MR_ID[0].iid)/pipelines" -Method Get) $PIPELINES+=$MR_PIPELINES } ## Sort pipelines by "updated_at" from earliest to latest and only retrieve the ones whose url contain our project namespaec.