1
0
mirror of https://git.libssh.org/projects/libssh.git synced 2025-12-08 03:42:12 +03:00

Run CI in merge requests and in branches

This should avoid duplicate pipelines as suggested in (gitlab-org/gitlab!230928)

Signed-off-by: Jakub Jelen <jjelen@redhat.com>
Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
This commit is contained in:
Jakub Jelen
2020-12-17 15:29:10 +01:00
parent 9cee4fa054
commit ed68fdaa61

View File

@@ -15,6 +15,17 @@ stages:
- test - test
- analysis - analysis
# This is some black magic to select between branch pipelines and
# merge request pipelines to avoid running same pipelines in twice
workflow:
rules:
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS && $CI_PIPELINE_SOURCE == "push"'
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
- if: '$CI_COMMIT_BRANCH'
.build: .build:
stage: build stage: build
variables: variables:
@@ -37,6 +48,10 @@ stages:
# Do not use after_script as it does not make the targets fail # Do not use after_script as it does not make the targets fail
tags: tags:
- shared - shared
only:
- merge_requests
- branches
except: except:
- tags - tags
artifacts: artifacts:
@@ -316,6 +331,11 @@ fedora/mingw32:
image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD image: $CI_REGISTRY/$BUILD_IMAGES_PROJECT:$FEDORA_BUILD
before_script: before_script:
- | - |
# for merge requests
if [[ -n "$CI_MERGE_REQUEST_DIFF_BASE_SHA" ]]; then
export CI_COMMIT_BEFORE_SHA="$CI_MERGE_REQUEST_DIFF_BASE_SHA"
fi
# for branches run
if [[ -z "$CI_COMMIT_BEFORE_SHA" ]]; then if [[ -z "$CI_COMMIT_BEFORE_SHA" ]]; then
export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20") export CI_COMMIT_BEFORE_SHA=$(git rev-parse "${CI_COMMIT_SHA}~20")
fi fi
@@ -329,6 +349,8 @@ fedora/mingw32:
- shared - shared
except: except:
- tags - tags
only:
- merge_requests
artifacts: artifacts:
expire_in: 1 week expire_in: 1 week
when: on_failure when: on_failure