-
Notifications
You must be signed in to change notification settings - Fork 5
/
.gitlab-ci.yml
98 lines (91 loc) · 2.52 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
variables:
DOCKER_TARGET_IMAGE: registry.ddbuild.io/ci/datadog-lambda-extension
DOCKER_TARGET_VERSION: latest
# Default version for development builds
# This will be overwritten by the tag version if it is a release.
VERSION: dev
# Manual trigger variables
AGENT_BRANCH:
description: "Branch of the datadog-agent repository to use."
value: main
AGENT_VERSION:
description: "Latest release version of the datadog-agent to tag the build with."
value: "7.55.1"
LAYER_SUFFIX:
description: "Suffix to be appended to the layer name (default empty)."
value: ""
stages:
- generate
- build
ci image:
stage: build
image: registry.ddbuild.io/images/docker:20.10
tags: ["arch:arm64"]
rules:
- if: '$CI_COMMIT_BRANCH == "main" && $CI_PIPELINE_SOURCE == "push"'
changes:
- .gitlab/Dockerfile
when: on_success
variables:
DOCKER_TARGET: ${DOCKER_TARGET_IMAGE}:${DOCKER_TARGET_VERSION}
script:
- docker buildx build --platform linux/amd64,linux/arm64 --no-cache --pull --push --tag ${DOCKER_TARGET} -f .gitlab/Dockerfile .
.go-cache: &go-cache
key: datadog-lambda-extension-go-cache
policy: pull
generator:
stage: generate
image: registry.ddbuild.io/images/mirror/golang:alpine
tags: ["arch:amd64"]
cache: *go-cache
artifacts:
paths:
- .gitlab/pipeline-bottlecap.yaml
- .gitlab/pipeline-go-agent.yaml
- .gitlab/pipeline-lambda-extension.yaml
reports:
dotenv: .env
script:
- if [[ "$CI_COMMIT_TAG" =~ ^v[0-9]+$ ]]; then echo "VERSION=${CI_COMMIT_TAG//[!0-9]/}" >> .env; fi
- apk add --no-cache gomplate
- gomplate --config .gitlab/config.yaml
bottlecap-only:
stage: build
trigger:
include:
- artifact: .gitlab/pipeline-bottlecap.yaml
job: generator
strategy: depend
rules:
- when: on_success
go-agent-only:
stage: build
trigger:
include:
- artifact: .gitlab/pipeline-go-agent.yaml
job: generator
strategy: depend
rules:
- if: $CI_PIPELINE_SOURCE == "web"
when: manual
variables:
AGENT_BRANCH: $AGENT_BRANCH
LAYER_SUFFIX: $LAYER_SUFFIX
AGENT_VERSION: $AGENT_VERSION
lambda-extension:
stage: build
trigger:
include:
- artifact: .gitlab/pipeline-lambda-extension.yaml
job: generator
strategy: depend
needs:
- job: generator
artifacts: true
rules:
- if: $CI_PIPELINE_SOURCE == "web"
variables:
VERSION: $VERSION
AGENT_BRANCH: $AGENT_BRANCH
LAYER_SUFFIX: $LAYER_SUFFIX
AGENT_VERSION: $AGENT_VERSION