diff --git a/.gitlab/ci/download/select_jobs.gitlab-ci.yml b/.gitlab/ci/download/select_jobs.gitlab-ci.yml index 88816d1d15ad9d357560d23f290896fe80344247..707c2710db39ee69b116f63cd2b901feb31a2ef3 100644 --- a/.gitlab/ci/download/select_jobs.gitlab-ci.yml +++ b/.gitlab/ci/download/select_jobs.gitlab-ci.yml @@ -3,8 +3,8 @@ ################################################################################################### .ubuntu:download:select_jobs: - # This task will retrieve specific jobs and store them in - # NOTE: this script do not work in standalone + # This task will retrieve specific jobs and store them in + # NOTE: this script do not work in standalone # it is meant to be called as part of the # following jobs : # - .ubuntu:download:repositories @@ -25,7 +25,7 @@ echo "*************************************************************************" echo "*************************************************************************" echo "**" - echo "** RETRIEVING \$DEP_NAME'S PROJECT ID" + echo "** RETRIEVING ${DEP_NAME^^}'S PROJECT ID" echo "**" echo "*************************************************************************" echo "*************************************************************************" @@ -161,8 +161,8 @@ --argjson mr_pipelines "$MR_PIPELINES" \ --arg project_namespace "$CI_PROJECT_NAMESPACE" \ '$pipelines + $mr_pipelines - | map(select(.web_url | test($project_namespace))) - | sort_by(.updated_at) + | map(select(.web_url | test($project_namespace))) + | sort_by(.updated_at) | reverse' ) if [[ ! -z "$CI_COMMIT_TAG" ]]; then @@ -210,7 +210,7 @@ repo : $repo_name, repo_id : $repo_id, branch_to_pull : $branch_name, - id, status, name, ref, created_at, updated_at, + id, status, name, ref, created_at, updated_at, user : { id : .user.id, username : .user.username }, commit : { author : .commit.author_name, id : .commit.id, message : .commit.message, authored_date : .commit.authored_date }, pipeline : { id : .pipeline.id, iid : .pipeline.iid, project_id : .pipeline.project_id, ref : .pipeline.ref}, @@ -273,7 +273,7 @@ foreach ($DEP_NAME in $DEPS_NAMES) { Write-Host "curr dep = $DEP_NAME" # Download dependencies - + ###################################################################################################### # Retrieve the ID of the project # Depending on wether the project is the official project or a user fork @@ -288,10 +288,10 @@ if ( $CI_PROJECT_NAMESPACE -match ".*eclipse/aidge.*" ){ # nominal case : we are in the official project Write-Host "Retrieve DEP ID from $API_URL/groups/$CI_PROJECT_NAMESPACE_ID/projects?search=$DEP_NAME" $DEP_ID=$( Invoke-RestMethod -Uri "$API_URL/groups/$CI_PROJECT_NAMESPACE_ID/projects?search=$DEP_NAME" -Method Get)[0].id - } else { + } else { # case for fork Write-Host "Forked repo detected : not on the official repo but on a user's forked project." - Write-Host "Retrieving USER_ID from : $API_URL/users?username=$CI_PROJECT_ROOT_NAMESPACE" + Write-Host "Retrieving USER_ID from : $API_URL/users?username=$CI_PROJECT_ROOT_NAMESPACE" $USER_ID=$(Invoke-RestMethod -Uri "$API_URL/users?username=$CI_PROJECT_ROOT_NAMESPACE" -Method Get)[0].id Write-Host "USER ID = $USER_ID" $DEP_ID=$(Invoke-RestMethod -Uri "$API_URL/users/$USER_ID/projects?search=${DEP_NAME}" -Method Get)[0].id @@ -326,7 +326,7 @@ Write-Host "NON DRAFT MERGE REQUEST Pipeline detected : Pulling from CI_MERGE_REQUEST_TARGET_BRANCH_NAME : $CI_MERGE_REQUEST_TARGET_BRANCH_NAME." Write-Host "Checking if CI_MERGE_REQUEST_TARGET_BRANCH_NAME "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" branch exists, otherwise pull from default." $FILTERED_BRANCHES=@($DEP_BRANCHES | Where-Object { $_.name -eq "$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"}) - + if ( ($FILTERED_BRANCHES.Count) -gt 0){ Write-Host "Found MR target branch in $DEP_NAME." $BRANCH_TO_PULL=$CI_MERGE_REQUEST_TARGET_BRANCH_NAME @@ -340,7 +340,7 @@ # CASE WHERE A COMMIT TAG IS CREATED } elseif ( "$CI_COMMIT_TAG" ) { Write-Host "Retrieving repo tags from $DEP_API_URL/repository/tags?per_page=100" - $DEP_TAGS = $($(Invoke-RestMethod -Uri "$DEP_API_URL/repository/tags?per_page=100" -Method Get) | + $DEP_TAGS = $($(Invoke-RestMethod -Uri "$DEP_API_URL/repository/tags?per_page=100" -Method Get) | Sort-Object -Property {[datetime]$_.commit.created_at} -Descending) if ( $DEP_TAGS.Count -eq 0 ) { Write-Host "No tag found for $DEP_NAME at url $DEP_API_URL/repository/tags?per_page=100" @@ -395,8 +395,8 @@ $PIPELINES | Out-String Write-Host "Sorting pipelines from newest to oldest & filtering out those not linked to CI_PROJECT_NAMESPACE ($CI_PROJECT_NAMESPACE)" - $PIPELINES = $PIPELINES | - Where-Object { $_.web_url -match $CI_PROJECT_NAMESPACE } | + $PIPELINES = $PIPELINES | + Where-Object { $_.web_url -match $CI_PROJECT_NAMESPACE } | Sort-Object -Property updated_at -Descending $PIPELINES = @($PIPELINES) Write-Host "Final Pipelines nb to parse : $($PIPELINES.Count)" @@ -420,7 +420,7 @@ $JOBS = @( $JOBS | Where-Object { $_.name -eq $DEPENDENCY_JOB -and $_.status -eq "success" } | - Select-Object @{Name="repo"; Expression={$DEP_NAME}}, + Select-Object @{Name="repo"; Expression={$DEP_NAME}}, id, status, @{Name="job_name"; Expression={$_.name}}, ref, @{Name="branch_to_pull"; Expression={$BRANCH_TO_PULL}}, created_at, updated_at, @@ -429,7 +429,7 @@ @{Name="pipeline"; Expression={[PSCustomObject]@{id=$_.pipeline.id; iid=$_.pipeline.iid; project_id=$_.pipeline.project_id; ref=$_.pipeline.ref}}} ) - if ( $JOBS.Count -gt 0 ) { + if ( $JOBS.Count -gt 0 ) { $FOUND_JOB=1 Write-Host "Successful job $DEPENDENCY_JOB found in branch $BRANCH_TO_PULL for project $DEP_NAME" Write-Host "Appending this jobs to the list of selected jobs that will serve as reference to retrieve artifact or specific commit." @@ -466,6 +466,6 @@ Write-Host "*" Write-Host "*************************************************************************" Write-Host "*************************************************************************" - Write-Host "SELECTED_JOBS = $($DEPS_SELECTED_JOBS | Out-String)" + Write-Host "SELECTED_JOBS = $($DEPS_SELECTED_JOBS | Out-String)" }