File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change 6
6
- build_and_test
7
7
8
8
.detect-branches :
9
- # Version 1 .
9
+ # Version 2 .
10
10
# Detects source and target branches. Checkout necessary branch for
11
11
# repository when run downstream pipeline is detected.
12
12
# ACI_SOURCE_BRANCH is set to source branch (merge request, pull)
@@ -47,10 +47,18 @@ stages:
47
47
48
48
# On downstream pipeline checkout the necessary branch
49
49
- if [[ "$CI_PIPELINE_SOURCE" == 'pipeline' ]]; then
50
- if `git -C $CI_PROJECT_DIR show-ref $ACI_SOURCE_BRANCH > /dev/null`; then
50
+ if `git -C $CI_PROJECT_DIR show-ref $ACI_SOURCE_BRANCH > /dev/null`; then
51
+ git -C $CI_PROJECT_DIR checkout $ACI_SOURCE_BRANCH;
52
+ elif `git -C $CI_PROJECT_DIR ls-remote --exit-code --heads origin $ACI_SOURCE_BRANCH > /dev/null`; then
53
+ git -C $CI_PROJECT_DIR config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
54
+ git -C $CI_PROJECT_DIR remote update
51
55
git -C $CI_PROJECT_DIR checkout $ACI_SOURCE_BRANCH;
52
56
elif `git -C $CI_PROJECT_DIR show-ref $ACI_TARGET_BRANCH > /dev/null`; then
53
57
git -C $CI_PROJECT_DIR checkout $ACI_TARGET_BRANCH;
58
+ elif `git -C $CI_PROJECT_DIR ls-remote --exit-code --heads origin $ACI_TARGET_BRANCH > /dev/null`; then
59
+ git -C $CI_PROJECT_DIR config remote.origin.fetch "+refs/heads/*:refs/remotes/origin/*"
60
+ git -C $CI_PROJECT_DIR remote update
61
+ git -C $CI_PROJECT_DIR checkout $ACI_TARGET_BRANCH;
54
62
fi
55
63
fi
56
64
You can’t perform that action at this time.
0 commit comments