-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy path.gitlab-ci.yml
155 lines (143 loc) · 4.73 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
include:
- /.gitlab/software_composition_analysis.yaml
- /.gitlab/build_agent.yaml
variables:
TAGGER_IMAGE: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/integrations-core:tagger
VALIDATE_LOG_INTGS: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/integrations-core:validate_log_intgs
VALIDATE_AGENT_BUILD: 486234852809.dkr.ecr.us-east-1.amazonaws.com/ci/integrations-core:validate_agent_build
NOTIFIER_IMAGE: 486234852809.dkr.ecr.us-east-1.amazonaws.com/slack-notifier:latest
TAGGER_EMAIL: [email protected]
TAGGER_NAME: ci.integrations-core
NOTIFICATIONS_SLACK_CHANNEL: agent-integrations
AGENT_BUILD_NOTIFICATIONS_SLACK_CHANNEL: agent-integrations-ops
stages:
- build
- validate
- release
- notify
cache: &slack-cache
key: integrations-core-slack-cache
paths:
- .slack-cache
policy: pull-push
validate-log-integrations:
stage: validate
needs: []
image: $VALIDATE_LOG_INTGS
only:
- schedules
variables:
INTEGRATIONS_CORE_ROOT: $CI_PROJECT_DIR
script:
- cd /app
- export WEBUI_INTGS_FILE=$(aws ssm get-parameter --region us-east-1 --name ci.integrations-core.webui_intgs_file --with-decryption --query "Parameter.Value" --out text)
- export LOGS_BACKEND_INTGS_ROOT=$(aws ssm get-parameter --region us-east-1 --name ci.integrations-core.logs_backend_intgs_root --with-decryption --query "Parameter.Value" --out text)
- git clone -b prod https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/Datadog/web-ui.git --depth 1
- ts-node parse_ts.ts > logs_integrations.json
- git clone -b prod https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.ddbuild.io/Datadog/logs-backend.git --depth 1
- python3 validate_log_intgs.py logs_integrations.json 2> $CI_PROJECT_DIR/errors.txt
artifacts:
paths:
- $CI_PROJECT_DIR/errors.txt
expire_in: 1 day
when: always
tags: [ "runner:main" ]
notify-slack:
needs:
- validate-log-integrations
stage: notify
image: $NOTIFIER_IMAGE
only:
- schedules
cache:
<<: *slack-cache
script:
- export SLACK_CACHE_DIR="${PWD}/.slack-cache"
- |
if [[ -s $CI_PROJECT_DIR/errors.txt ]]; then
cat $CI_PROJECT_DIR/errors.txt
MESSAGE="Logs pipelines don't pass validation steps, please investigate $CI_JOB_URL for errors."
postmessage "$NOTIFICATIONS_SLACK_CHANNEL" "$MESSAGE" alert
else
MESSAGE="Logs pipelines passed validation steps, good job :+1:"
postmessage "$NOTIFICATIONS_SLACK_CHANNEL" "$MESSAGE" success
fi
tags: [ "runner:main" ]
notify-failed-pipeline:
stage: notify
image: $NOTIFIER_IMAGE
only:
- master
when: on_failure
cache:
<<: *slack-cache
script:
- export SLACK_CACHE_DIR="${PWD}/.slack-cache"
- |
MESSAGE="The pipeline encountered an unexpected error in job $CI_JOB_NAME. Please investigate $CI_JOB_URL for errors."
postmessage "$NOTIFICATIONS_SLACK_CHANNEL" "$MESSAGE" alert
tags: [ "runner:main" ]
release-auto:
stage: release
image: $TAGGER_IMAGE
only:
- master
- /^\d+\.\d+\.x$/
except:
- schedules
script:
- ddev --version
- ddev config set core .
# Prefix every line with a timestamp
- ./.gitlab/tagger/tag-release.sh 2>&1 | ts "[%H:%M:%S %Z] "
tags: [ "runner:main" ]
needs: []
release-manual:
stage: release
image: $TAGGER_IMAGE
only:
# Integration release tags e.g. any_check-X.Y.Z-rc.N
- /.*-\d+\.\d+\.\d+(-(rc|pre|alpha|beta)\.\d+)?$/
except:
- schedules
script:
# Get tagger info
- tagger=$(git for-each-ref refs/tags/$CI_COMMIT_TAG --format='%(taggername) %(taggeremail)')
# The automatic release builder will trigger this job as a side-effect of
# tagging releases. To prevent multiple redundant builds we don't trigger
# the pipeline unless the tag was applied manually.
- |
if [[ "$tagger" =~ "$TAGGER_NAME <$TAGGER_EMAIL>" ]]; then
echo "Skipping, packages have already been built"
else
./.gitlab/tagger/build-packages.sh
fi
tags: [ "runner:main" ]
needs: []
tagger-image-builder:
stage: build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:24.0.4-gbi-focal
only:
changes:
- .gitlab/tagger/**/*
- ddev/**/*
- .gitlab-ci.yml
refs:
- master
script:
- docker buildx build --tag $TAGGER_IMAGE -f .gitlab/tagger/Dockerfile . --push
except: [ tags, schedules ]
tags: [ "arch:amd64" ]
validate-log-intgs-builder:
stage: build
image: 486234852809.dkr.ecr.us-east-1.amazonaws.com/docker:24.0.4-gbi-focal
only:
changes:
- .gitlab/validate-logs-intgs/**/*
- .gitlab-ci.yml
refs:
- master
script:
- cd .gitlab/validate-logs-intgs/
- docker buildx build --tag $VALIDATE_LOG_INTGS . --push
tags: [ "arch:amd64" ]