Skip to content
Snippets Groups Projects
Commit f64c77f9 authored by Cyril Moineau's avatar Cyril Moineau
Browse files

Add download_dependency_windows script.

parent 9ec85a9b
No related branches found
No related tags found
No related merge requests found
...@@ -31,3 +31,68 @@ ...@@ -31,3 +31,68 @@
- curl -f --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/$DEPENDENCY_ID/jobs/artifacts/$BRANCH_TO_PULL/download?job=$DEPENDENCY_JOB" - curl -f --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/$DEPENDENCY_ID/jobs/artifacts/$BRANCH_TO_PULL/download?job=$DEPENDENCY_JOB"
- unzip -o build_artifacts.zip -d . - unzip -o build_artifacts.zip -d .
- rm -rf build_cpp - rm -rf build_cpp
.download_dependency_windows:
# Note:
# For this script to work you need to define teh following variables
# - DEPENDENCY_NAME: Name of the dependency project
# - DEPENDENCY_JOB: Name of the dependency job from which you want to pull artifacts
script:
# Download dependencies
- $BRANCH_TO_PULL="dev" # default branch
- $STATUS_CODE_TARGET
# Check CI_MERGE_REQUEST_TARGET_BRANCH_NAME is available on dependency
- >
try {
$response = Invoke-RestMethod -Uri "https://gitlab.eclipse.org/eclipse/aidge/$DEPENDENCY_NAME/-/tree/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" -Method Get
$STATUS_CODE_TARGET=$response.StatusCode
} catch {
# Handle specific status codes
if ($_.Exception.Response -ne $null) {
$STATUS_CODE_TARGET = [int]$($_.Exception.Response.StatusCode)
} else {
Write-Host "Error: $($_.Exception.Message)"
}
}
- $STATUS_CODE_NAME
# Check CI_MERGE_REQUEST_TARGET_BRANCH_NAME is available on dependency
- >
try {
$response = Invoke-RestMethod -Uri "https://gitlab.eclipse.org/eclipse/aidge/$DEPENDENCY_NAME/-/tree/$CI_COMMIT_REF_NAME" -Method Get
$STATUS_CODE_NAME=$response.StatusCode
} catch {
# Handle specific status codes
if ($_.Exception.Response -ne $null) {
$STATUS_CODE_NAME = [int]$($_.Exception.Response.StatusCode)
} else {
Write-Host "Error: $($_.Exception.Message)"
}
}
- $DependencyId=(Invoke-RestMethod -Uri "https://gitlab.eclipse.org/api/v4/groups/$CI_PROJECT_NAMESPACE_ID/projects?search=$DEPENDENCY_NAME" -Method Get)[0].id
- >
if ($CI_MERGE_REQUEST_ID) {
Write-Host "Merge request pipeline detected"
if ($STATUS_CODE_TARGET -eq 404) {
Write-Host "Pull from default MR"
}
else {
# Pulling from target branch
Write-Host "Pull from $($CI_MERGE_REQUEST_TARGET_BRANCH_NAME)"
$BRANCH_TO_PULL = $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
}
}
elseif ($STATUS_CODE_NAME -eq 404) {
Write-Host "Pull from default"
}
else {
# Pulling from branch with the same name
Write-Host "Pull from branch name"
$BRANCH_TO_PULL = $CI_COMMIT_REF_NAME
}
- Write-Host "curling from https://gitlab.eclipse.org/api/v4/projects/5139/jobs/artifacts/$BRANCH_TO_PULL/download?job=$DEPENDENCY_JOB"
- 'curl "https://gitlab.eclipse.org/api/v4/projects/$DependencyId/jobs/artifacts/$BRANCH_TO_PULL/download?job=$DEPENDENCY_JOB" -o build_artifacts.zip'
- Expand-Archive -Path build_artifacts.zip -DestinationPath . -Force
- Remove-Item .\build_cpp\ -Recurse -ErrorAction Ignore
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