diff --git a/.gitlab/ci/build.gitlab-ci.yml b/.gitlab/ci/build.gitlab-ci.yml index dee38e74a95c09b498fe7c26a9a17a835f1a5ece..e93b9df56f819a65a0adeea8d7d5058ec71bdca5 100644 --- a/.gitlab/ci/build.gitlab-ci.yml +++ b/.gitlab/ci/build.gitlab-ci.yml @@ -15,6 +15,7 @@ build:ubuntu_cpp: - apt-get -qq install -y jq # Check if a branch with the same name exist on the dependance repository - BRANCH_TO_PULL="dev" # default branch + - set -x - > if [ "$CI_MERGE_REQUEST_ID" ]; then echo "Merge request pipeline detected" @@ -26,16 +27,20 @@ build:ubuntu_cpp: BRANCH_TO_PULL=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} fi # checking if given branch exist on official repo or on fork - elif [[ $(curl -s -o /dev/null -w "%{http_code}" "https://gitlab.eclipse.org/eclipse/aidge/$DEPENDENCY_NAME/-/tree/$CI_COMMIT_REF_NAME") -ne 404 || $(curl -s -o /dev/null -w "%{http_code}" "https://gitlab.eclipse.org/hrouis/$DEPENDENCY_NAME/-/tree/$CI_COMMIT_REF_NAME") -ne 404 ]]; then + elif [[ $(curl -s -o /dev/null -w "%{http_code}" "https://gitlab.eclipse.org/eclipse/aidge/$DEPENDENCY_NAME/-/tree/$CI_COMMIT_REF_NAME") -ne 404 ]] + PULL_FROM_FORK=FALSE + BRANCH_TO_PULL=$CI_COMMIT_REF_NAME + elif [[$(curl -s -o /dev/null -w "%{http_code}" "https://gitlab.eclipse.org/hrouis/$DEPENDENCY_NAME/-/tree/$CI_COMMIT_REF_NAME") -ne 404 ]]; then + PULL_FROM_FORK=TRUE BRANCH_TO_PULL=$CI_COMMIT_REF_NAME else - echo "No branch \"$CI_COMMIT_REF_NAME\" found for repository \"$DEPENDENCY_NAME\"" + PULL_FROM_FORK=FALSE + echo "No branch \"$CI_COMMIT_REF_NAME\" found for \"$DEPENDENCY_NAME\" in official or forked repos." fi - echo "Pulling from branch:\"$BRANCH_TO_PULL\"" - # Check group namespace is valid, if it is then we are in the official project(aidge group id=6437), otherwise we pull from the fork - # nominal case : we are in the official project + - set +x - > - if [ "$(curl -s -o /dev/null -w "%{http_code}" "https://gitlab.eclipse.org/api/v4/groups/${CI_PROJECT_NAMESPACE_ID}")" != "404" ]; then + if [[ ! $PULL_FROM_FORK ]]; then # nominal case : we are in the official project DEPENDENCY_ID=$(curl "https://gitlab.eclipse.org/api/v4/groups/${CI_PROJECT_NAMESPACE_ID}/projects?search=${DEPENDENCY_NAME}" | jq -r '.[0].id') else # case for fork echo "Retrieving build_artifacts from hrouis' forked project."