Skip to content
Snippets Groups Projects
Commit d4ec2c10 authored by Grégoire Kubler's avatar Grégoire Kubler
Browse files

feat : refactor branch to pull

parent a3a25ce3
No related branches found
No related tags found
1 merge request!47Draft: TEST_CI_FORK_DO_NOT_MERGE
......@@ -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."
......
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