-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtraceability.yml
More file actions
48 lines (44 loc) · 1.6 KB
/
Copy pathtraceability.yml
File metadata and controls
48 lines (44 loc) · 1.6 KB
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
# GitLab CI template. Include it from .gitlab-ci.yml:
#
# include:
# - remote: "https://raw.githubusercontent.com/royzah/traceability-helper/v1/ci/gitlab/traceability.yml"
#
# Set these as CI/CD variables (Settings > CI/CD > Variables), masked:
# TRACKER_PROVIDER, PROJECT_KEYS, and the selected provider's secrets
# (for example JIRA_BASE_URL, JIRA_USER_EMAIL, JIRA_API_TOKEN). Provider
# secrets are read straight from the job environment.
.traceability-base:
image: python:3.11-slim
variables:
HELPER_REF: "v1"
HELPER_REPO: "https://github.com/royzah/traceability-helper.git"
CI_HOST: "gitlab"
before_script:
- apt-get update -qq && apt-get install -y -qq git >/dev/null
- git clone --depth 1 --branch "$HELPER_REF" "$HELPER_REPO" /opt/helper
- pip install --no-cache-dir -r /opt/helper/tools/requirements.txt
traceability:validate:
extends: .traceability-base
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
script:
- PATTERN="${KEY_PATTERN:-[A-Z][A-Z0-9]{1,9}-[0-9]+}"
- echo "branch ${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}"
- echo "${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}" | grep -Eq "$PATTERN" ||
{ echo "branch is missing an issue key"; exit 1; }
traceability:review:
extends: .traceability-base
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
variables:
TRACKER_EVENT: "opened"
script:
- python /opt/helper/tools/sync.py
traceability:done:
extends: .traceability-base
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
TRACKER_EVENT: "merged"
script:
- python /opt/helper/tools/sync.py