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 66 - build_and_test
77
88.detect-branches :
9- # Version 1 .
9+ # Version 2 .
1010 # Detects source and target branches. Checkout necessary branch for
1111 # repository when run downstream pipeline is detected.
1212 # ACI_SOURCE_BRANCH is set to source branch (merge request, pull)
@@ -47,10 +47,18 @@ stages:
4747
4848 # On downstream pipeline checkout the necessary branch
4949 - 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
5155 git -C $CI_PROJECT_DIR checkout $ACI_SOURCE_BRANCH;
5256 elif `git -C $CI_PROJECT_DIR show-ref $ACI_TARGET_BRANCH > /dev/null`; then
5357 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;
5462 fi
5563 fi
5664
You can’t perform that action at this time.
0 commit comments