Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
gitlab_shared_files
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Eclipse Projects
aidge
gitlab_shared_files
Commits
189311fe
Commit
189311fe
authored
1 year ago
by
Cyril Moineau
Browse files
Options
Downloads
Patches
Plain Diff
Update fork case.
parent
6b49aa00
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.gitlab/ci/shared_script.gitlab-ci.yml
+9
-17
9 additions, 17 deletions
.gitlab/ci/shared_script.gitlab-ci.yml
with
9 additions
and
17 deletions
.gitlab/ci/shared_script.gitlab-ci.yml
+
9
−
17
View file @
189311fe
...
...
@@ -8,39 +8,32 @@
-
apt-get -qq install -y jq
-
GITLAB_ECLIPSE_URL="https://gitlab.eclipse.org/"
-
API_URL="https://gitlab.eclipse.org/api/v4"
-
echo "CI project namespace $CI_PROJECT_NAMESPACE"
# Check if a branch with the same name exist on the dependency repository
-
BRANCH_TO_PULL="dev"
# default branch
-
>
if [ "$CI_MERGE_REQUEST_ID" ]; then # CASE MERGE REQUEST
echo "Merge request pipeline detected"
if [ $(curl -s -o /dev/null -w "%{http_code}" "$GITLAB_ECLIPSE_URL/eclipse/aidge/$DEPENDENCY_NAME/-/tree/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME") -eq 404 ]; then
echo "Pull from default"
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}
# Pulling from target branch
echo "Pull from ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}"
BRANCH_TO_PULL=${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}
fi
else # CASE CASUAL COMMIT
echo "TEST : $GITLAB_ECLIPSE_URL/
eclipse/
$CI_PROJECT_NAMESPACE/$DEPENDENCY_NAME/-/tree/$CI_COMMIT_REF_NAME"
echo "TEST : $GITLAB_ECLIPSE_URL/$CI_PROJECT_NAMESPACE/$DEPENDENCY_NAME/-/tree/$CI_COMMIT_REF_NAME"
# checking if given branch exist on official repo or on fork
RETURN_HTTP_CODE_OFFICIAL_REPO=$(curl -s -o /dev/null -w "%{http_code}" "$GITLAB_ECLIPSE_URL/eclipse/$CI_PROJECT_NAMESPACE/$DEPENDENCY_NAME/-/tree/$CI_COMMIT_REF_NAME")
RETURN_HTTP_CODE_FORK=$(curl -s -o /dev/null -w "%{http_code}" "$GITLAB_ECLIPSE_URL/$CI_PROJECT_NAMESPACE/$DEPENDENCY_NAME/-/tree/$CI_COMMIT_REF_NAME")
if [[ $RETURN_HTTP_CODE_OFFICIAL_REPO -ne 302 && $RETURN_HTTP_CODE_OFFICIAL_REPO -ne 404 ]]; then
PULL_FROM_FORK=FALSE
BRANCH_TO_PULL=$CI_COMMIT_REF_NAME
elif [[ $RETURN_HTTP_CODE_FORK -ne 302 && $RETURN_HTTP_CODE_FORK -ne 302 ]]; then
PULL_FROM_FORK=TRUE
RETURN_HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" "$GITLAB_ECLIPSE_URL/$CI_PROJECT_NAMESPACE/$DEPENDENCY_NAME/-/tree/$CI_COMMIT_REF_NAME")
if [[ $RETURN_HTTP_CODE -ne 302 && $RETURN_HTTP_CODE -ne 404 ]]; then
BRANCH_TO_PULL=$CI_COMMIT_REF_NAME
else
PULL_FROM_FORK=FALSE
echo "No branch \"$CI_COMMIT_REF_NAME\" found for \"$DEPENDENCY_NAME\" in official or forked repos."
fi
fi
-
echo "Pulling from branch:\"$BRANCH_TO_PULL\""
-
>
if [[
! $PULL_FROM_FORK
]]; then # nominal case : we are in the official project
if [[
$CI_PROJECT_NAMESPACE =~ "aidge/eclipse"
]]; then # nominal case : we are in the official project
DEPENDENCY_ID=$(curl "${API_URL}/groups/${CI_PROJECT_NAMESPACE_ID}/projects?search=${DEPENDENCY_NAME}" | jq -r '.[0].id')
else # case for fork
echo "Retrieving build_artifacts from user' forked project."
...
...
@@ -136,4 +129,3 @@
-
'
curl
"https://gitlab.eclipse.org/api/v4/projects/$DependencyId/jobs/artifacts/$BRANCH_TO_PULL/download?job=$DEPENDENCY_JOB"
-o
build_artifacts.zip'
-
Expand-Archive -Path build_artifacts.zip -DestinationPath . -Force
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment