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

Refactor download_dependency script for better future debugging.

parent 8c93ea4b
No related branches found
No related tags found
No related merge requests found
......@@ -4,25 +4,26 @@
# - DEPENDENCY_NAME: Name of the dependency project
# - DEPENDENCY_JOB: Name of the dependency job from which you want to pull artifacts
script:
- DEFAULT_BRANCH="dev"
-BRANCH_TO_PULL="dev" # default branch
# Check if a branch with the same name exist on the dependance repository
- >
if [ "$CI_MERGE_REQUEST_ID" ]; then
if [ $(curl -s -o /dev/null -w "%{http_code}" "https://gitlab.eclipse.org/eclipse/aidge/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME/-/tree/$CI_COMMIT_REF_NAME") -eq 404 ]; then
echo "Pull from ${DEFAULT_BRANCH}"
curl --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/$CI_PROJECT_ID/jobs/artifacts/$DEFAULT_BRANCH/download?job=$JOB"
else
# Pulling from target branch
echo "Pull from ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}"
curl --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/$CI_PROJECT_ID/jobs/artifacts/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME/download?job=$JOB"
fi
echo "Merge request pipeline detected"
if [ $(curl -s -o /dev/null -w "%{http_code}" "https://gitlab.eclipse.org/eclipse/aidge/$DEPENDENCY_NAME/-/tree/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME") -eq 404 ]; then
echo "Pull from default"
else
# Pulling from target branch
echo "Pull from ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}"
BRANCH_TO_PULL=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}
fi
elif [ $(curl -s -o /dev/null -w "%{http_code}" "https://gitlab.eclipse.org/eclipse/aidge/$DEPENDENCY_NAME/-/tree/$CI_COMMIT_REF_NAME") -eq 404 ]; then
echo "Pull from ${DEFAULT_BRANCH}"
curl --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/$CI_PROJECT_ID/jobs/artifacts/$DEFAULT_BRANCH/download?job=$JOB"
echo "Pull from default"
else
# Pulling from branch with same name
echo "Pull from ${CI_COMMIT_REF_NAME}"
curl --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/$CI_PROJECT_ID/jobs/artifacts/$CI_COMMIT_REF_NAME/download?job=$JOB"
# Pulling from branch with same name
echo "Pull from branch name"
BRANCH_TO_PULL=${CI_COMMIT_REF_NAME}
fi
- echo "curling from https://gitlab.eclipse.org/api/v4/projects/$CI_PROJECT_ID/jobs/artifacts/$BRANCH_TO_PULL/download?job=$DEPENDENCY_JOB"
- curl -f --location --output build_artifacts.zip "https://gitlab.eclipse.org/api/v4/projects/$CI_PROJECT_ID/jobs/artifacts/$BRANCH_TO_PULL/download?job=$DEPENDENCY_JOB"
- unzip -o build_artifacts.zip -d .
- rm -rf build_cpp
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