From ff33227f195527a500b5af24e1f970ebc5cae052 Mon Sep 17 00:00:00 2001 From: cmoineau <cyril.moineau@cea.fr> Date: Thu, 1 Feb 2024 08:42:17 +0000 Subject: [PATCH] Refactor download_dependency script for better future debugging. --- .gitlab/ci/shared_script.gitlab-ci.yml | 29 +++++++++++++------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/.gitlab/ci/shared_script.gitlab-ci.yml b/.gitlab/ci/shared_script.gitlab-ci.yml index f44d308..4894ecf 100644 --- a/.gitlab/ci/shared_script.gitlab-ci.yml +++ b/.gitlab/ci/shared_script.gitlab-ci.yml @@ -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 -- GitLab