diff --git a/.gitlab/ci/build.gitlab-ci.yml b/.gitlab/ci/build.gitlab-ci.yml index 39d5a378b7ed94b0455ad5cd36464b180c52c535..a5b3fda20f8a7479780ca769c409d9401c142ee4 100644 --- a/.gitlab/ci/build.gitlab-ci.yml +++ b/.gitlab/ci/build.gitlab-ci.yml @@ -11,7 +11,45 @@ build:ubuntu_cpp: # aidge_core - DEPENDENCY_NAME="aidge_core" - DEPENDENCY_JOB="build:ubuntu_cpp" - - !reference [.download_dependency, script] + # - !reference [.download_dependency, script] + - set -x + - 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 + 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" + else + # Pulling from branch with same name + echo "Pull from branch name" + BRANCH_TO_PULL=${CI_COMMIT_REF_NAME} + fi + - apt-get install -y jq + # Check group namespace is valid, if not DEPENDENCY_ID=6437 (aidge group ID) + - > + if [ $(curl -s -o /dev/null -w "%{http_code}" "https://gitlab.eclipse.org/api/v4/groups/${CI_PROJECT_NAMESPACE_ID}") -eq 404 ]; then + echo "Using aidge group id by default" + DEPENDENCY_ID=$(curl "https://gitlab.eclipse.org/api/v4/groups/6437/projects?search=${DEPENDENCY_NAME}" | jq -r '.[0].id') + else + DEPENDENCY_ID=$(curl "https://gitlab.eclipse.org/api/v4/groups/${CI_PROJECT_NAMESPACE_ID}/projects?search=${DEPENDENCY_NAME}" | jq -r '.[0].id') + fi + - echo "Project ID for ${DEPENDENCY_NAME} is ${DEPENDENCY_ID}" + + - echo "curling from 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" + - set +x + - unzip -q -o build_artifacts.zip -d . + - rm -rf build_cpp + # end !reference[] + # Build current module - export CMAKE_PREFIX_PATH=../install_cpp