-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
68 lines (62 loc) · 2.36 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
stages:
- decision
- generated-pipeline
variables:
TARGET_JOBS_METHOD: default # Can be overriden by schedules
decision:
artifacts:
expire_in: 1 year
paths:
- jobgraph-artifacts/*
image: registry.gitlab.com/jobgraph-dev/jobgraph/jobgraph:latest@sha256:c8dc9f582fba795534a875952b8ae23c7744085bd23dbde830c7b4848520d37d
retry:
max: 2
when:
- unknown_failure
- stale_schedule
- runner_system_failure
- stuck_or_timeout_failure
script:
# We reinstall jobgraph to use the cloned version instead of the version in the docker image
- pip install --prefix "/runner/.local" --no-deps --editable "$CI_PROJECT_DIR"
- >-
if [ -n "$CI_MERGE_REQUEST_SOURCE_PROJECT_URL" ] && [ "$CI_MERGE_REQUEST_SOURCE_PROJECT_URL" != '' ]; then
export BASE_REPOSITORY="$CI_MERGE_REQUEST_SOURCE_PROJECT_URL"
else
export BASE_REPOSITORY="$CI_PROJECT_URL"
fi
# We fetch the main branch of the repository so that jobgraph can determine
# the actual base revision in case $CI_COMMIT_BEFORE_SHA equals
# "0000000000000000000000000000000000000000".
#
# See https://docs.gitlab.com/ee/ci/variables/predefined_variables.html
- export DEFAULT_BRANCH_SHORT_NAME="$(git ls-remote --symref origin HEAD | awk '/^ref:/ {sub(/refs\/heads\//, "", $2); print $2}')"
- git fetch "$GIT_REMOTE_NAME" "$DEFAULT_BRANCH_SHORT_NAME"
- >-
jobgraph decision
--base-repository="$BASE_REPOSITORY"
--base-rev="$CI_COMMIT_BEFORE_SHA"
--head-ref="$CI_COMMIT_BRANCH"
--head-repository="$CI_PROJECT_URL"
--head-rev="$CI_COMMIT_SHA"
--head-tag="$CI_COMMIT_TAG"
--is-head-ref-protected="$CI_COMMIT_REF_PROTECTED"
--message="$CI_COMMIT_MESSAGE"
--owner="$CI_COMMIT_AUTHOR"
--pipeline-id="$CI_PIPELINE_ID"
--pipeline-source="$CI_PIPELINE_SOURCE"
--target-jobs-method="$TARGET_JOBS_METHOD"
stage: decision
variables:
GET_SOURCES_ATTEMPTS: 3
# We need the full history to ensure jobgraph makes the right decisions
GIT_DEPTH: 0
GIT_REMOTE_NAME: origin
generated-pipeline:
stage: generated-pipeline
trigger:
include:
- artifact: jobgraph-artifacts/generated-gitlab-ci.yml
job: decision
strategy: depend