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

Fix windows fork mr id retrieval

parent 7abddc1c
No related branches found
No related tags found
1 merge request!11Fix windows fork mr id retrieval
...@@ -101,14 +101,14 @@ ...@@ -101,14 +101,14 @@
echo "Retrieving pipelines from $BRANCH_TO_PULL" echo "Retrieving pipelines from $BRANCH_TO_PULL"
echo "Regular pipeline curled from \"$API_URL/projects/$DEP_ID/pipelines?ref=${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}") 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\"" 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" | jq '.[0].iid') 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 if [[ $MR_ID != null ]]; then
echo "MR pipeline curled from \"$API_URL/projects/$DEP_ID/merge_requests/$MR_ID/pipelines\"" 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") 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 else
echo "No merge request with source_branch = \"$BRANCH_TO_PULL\" found." echo "No merge request with source_branch = \"$BRANCH_TO_PULL\" found."
MR_PIPELINES="[]" MR_PIPELINES="[]"
...@@ -316,12 +316,12 @@ ...@@ -316,12 +316,12 @@
Write-Host "****************************************************************************************************************************" Write-Host "****************************************************************************************************************************"
Write-Host "Retrieving regular pipelines from $API_URL/projects/$DEP_ID/pipelines?ref=$BRANCH_TO_PULL" 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) $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 "Found $($PIPELINES.Count) pipelines with $BRANCH_TO_PULL as ref."
Write-Host "Retrieving MR pipelines from $API_URL/projects/$DEP_ID/merge_requests?source_branch=$BRANCH_TO_PULL" 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" -Method Get) $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) MR with $BRANCH_TO_PULL as source branch." Write-Host "Found $($MR_ID.Count) opened MR with $BRANCH_TO_PULL as source branch."
if ( $MR_ID.Count -ne 0 ){ 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 $PIPELINES+=$MR_PIPELINES
} }
## Sort pipelines by "updated_at" from earliest to latest and only retrieve the ones whose url contain our project namespaec. ## Sort pipelines by "updated_at" from earliest to latest and only retrieve the ones whose url contain our project namespaec.
......
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