forked from jfrog/jfrog-pipelines-dynatrace-example
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpipelines.yml
214 lines (200 loc) · 8.02 KB
/
pipelines.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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
template: true
valuesFilePath: ./values.yml
resources:
- name: gitRepo
type: GitRepo
configuration:
gitProvider: {{ .Values.gitRepo.gitProvider }}
path: {{ .Values.gitRepo.path }}
branches:
include: {{ .Values.gitRepo.branch }}
buildOn:
commit: true
- name: demoappDockerImage
type: Image
configuration:
registry: artifactoryIntegration
sourceRepository: default-docker-local
imageName: {{ .Values.image.imageName }}
imageTag: ${BUILD_NUMBER}
- name: demoappBuildInfo
type: BuildInfo
configuration:
sourceArtifactory: artifactoryIntegration
buildName: demoapp
buildNumber: ${BUILD_NUMBER}
- name: demoappHelmChart
type: HelmChart
configuration:
sourceArtifactory: artifactoryIntegration
repository: art-helm-charts-dynatrace
chart: demoapp
version: 0.0.0
pipelines:
- name: dynatraceDemo
configuration:
environmentVariables:
readOnly:
DT_TAG_PROJECT: "dynatrace-demos"
DT_TAG_STAGE: "dev"
DT_TAG_SERVICE: "demoapp"
FEATURE_NUMBER: "1"
steps:
- name: aDockerBuild
type: DockerBuild
configuration:
affinityGroup: buildAndPush
integrations:
- name: artifactoryIntegration
inputResources:
- name: gitRepo
dockerFileLocation: demoapp
dockerFileName: Dockerfile
dockerImageName: {{ .Values.image.imageName }}
dockerImageTag: ${BUILD_NUMBER}
dockerOptions: --build-arg FEATURE_NUMBER=${FEATURE_NUMBER}
execution:
onStart:
- add_run_variables BUILD_NUMBER=0.${FEATURE_NUMBER}.${run_number}
- name: bDockerPush
type: DockerPush
configuration:
affinityGroup: buildAndPush
autoPublishBuildInfo: true
integrations:
- name: artifactoryIntegration
targetRepository: art-docker-dynatrace
inputSteps:
- name: aDockerBuild
outputResources:
- name: demoappBuildInfo
- name: demoappDockerImage
- name: cHelmPublish
type: HelmPublish
configuration:
affinityGroup: HelmPublish
helmVersion: 3
chartPath: chart
inputSteps:
- name: bDockerPush
inputResources:
- name: gitRepo
trigger: false
- name: demoappDockerImage
outputResources:
- name: demoappHelmChart
execution:
onStart:
- APP_VERSION=0.${FEATURE_NUMBER}.${run_number}
- VALUES_IMAGE=${res_demoappDockerImage_imageName}
- VALUES_TAG=${res_demoappDockerImage_imageTag}
- echo "CHART_VERSION = $CHART_VERSION"
- echo "VALUES_IMAGE = $VALUES_IMAGE"
- echo "VALUES_TAG = $VALUES_TAG"
- pushd $res_gitRepo_resourcePath/chart
- "sed -ie \"s|^image: .*$|image: $VALUES_IMAGE|\" values.yaml"
- "sed -ie \"s|^imageTag: .*$|imageTag: $VALUES_TAG|\" values.yaml"
- "sed -ie \"s|^appVersion: .*$|appVersion: $APP_VERSION|\" Chart.yaml"
- cat values.yaml
- cat Chart.yaml
- popd
- name: dHelmDeploy
type: HelmDeploy
configuration:
lint: true
dryRun: true
helmVersion: 3
affinityGroup: HelmDeploy
releaseName: demoapp
integrations:
- name: k8sIntegration
- name: artifactoryIntegration
inputResources:
- name: demoappHelmChart
- name: demoappDockerImage
inputSteps:
- name: cHelmPublish
execution:
onSuccess:
- kubectl config current-context
- kubectl get pods --all-namespaces
- add_run_variables CLUSTER="$(kubectl config current-context)"
- name: eAppUpCheck
type: Bash
configuration:
affinityGroup: HelmDeploy
inputResources:
- name: gitRepo
integrations:
- name: k8sIntegration
inputSteps:
- name: dHelmDeploy
execution:
onExecute:
- kubectl config current-context
- APP_IP=$(kubectl -n dev get service demoapp -o jsonpath="{.status.loadBalancer.ingress[0].ip}")
- add_run_variables APP_URL="http://${APP_IP}:8080"
- $res_gitRepo_resourcePath/scripts/appUpCheck.sh ${APP_URL}
- name: fModifyHelmChartProperties
type: Bash
configuration:
affinityGroup: Configuration
integrations:
- name: artifactoryIntegration
inputResources:
- name: demoappHelmChart
- name: gitRepo
inputSteps:
- name: eAppUpCheck
execution:
onExecute:
- JFROG_BASE_URL=${int_artifactoryIntegration_url}
- JFROG_API_KEY=${int_artifactoryIntegration_apikey}
- CHART_REPO=${res_demoappHelmChart_repository}
- add_run_variables CHART=demoapp-${res_demoappHelmChart_version}
- $res_gitRepo_resourcePath/scripts/updateHelmChartProperties.sh ${JFROG_BASE_URL} ${JFROG_API_KEY} ${CHART_REPO} ${CHART} ${CLUSTER}
- name: gConfigureDynatrace
type: Bash
configuration:
affinityGroup: Configuration
runtime:
type: host
inputResources:
- name: gitRepo
integrations:
- name: dynatraceIntegration
inputSteps:
- name: fModifyHelmChartProperties
execution:
onExecute:
- DT_BASEURL=${int_dynatraceIntegration_DT_URL}
- DT_API_TOKEN=${int_dynatraceIntegration_DT_API_TOKEN}
- docker run -e DT_BASEURL=$DT_BASEURL -e DT_API_TOKEN=$DT_API_TOKEN -e NEW_CLI=1 -v $res_gitRepo_resourcePath:/monaco-mount/ dynatraceace/monaco-runner:release-v1.5.3 "monaco deploy -v --environments /monaco-mount/monaco/environments.yml --project demoapp /monaco-mount/monaco/projects"
- name: hPostDynatraceEvent
type: Bash
configuration:
affinityGroup: Configuration
integrations:
- name: dynatraceIntegration
inputResources:
- name: gitRepo
- name: demoappHelmChart
- name: demoappDockerImage
inputSteps:
- name: gConfigureDynatrace
execution:
onExecute:
- DT_BASEURL=${int_dynatraceIntegration_DT_URL}
- DT_API_TOKEN=${int_dynatraceIntegration_DT_API_TOKEN}
- DEPLOYMENT_PROJECT=DemoProject
- DEPLOYMENT_VERSION=${BUILD_NUMBER}
- CI_BACK_LINK=${JFROG_CLI_BUILD_URL}
- SOURCE="JFrog"
- IMAGE_NAME="${res_demoappDockerImage_imageName}:${res_demoappDockerImage_imageTag}"
- HELM_CHART="${CHART}"
- PIPELINE_REPO=${res_gitRepo_gitRepoRepositoryUrl}
- JFROG_PIPELINE_NAME=${pipeline_name}
- JFROG_RUN_NUMBER=${run_number}
- JFROG_PROJECT=${project_name}
- TAG_RULE="{\"meTypes\":[\"PROCESS_GROUP_INSTANCE\"],\"tags\":[{\"context\":\"CONTEXTLESS\",\"key\":\"service\",\"value\":\"$DT_TAG_SERVICE\"},{\"context\":\"CONTEXTLESS\",\"key\":\"project\",\"value\":\"$DT_TAG_PROJECT\"},{\"context\":\"CONTEXTLESS\",\"key\":\"stage\",\"value\":\"$DT_TAG_STAGE\"}]}"
- $res_gitRepo_resourcePath/scripts/sendDynatraceEvent.sh ${DT_BASEURL} ${DT_API_TOKEN} ${DEPLOYMENT_PROJECT} ${DEPLOYMENT_VERSION} ${CI_BACK_LINK} ${SOURCE} ${IMAGE_NAME} ${HELM_CHART} ${PIPELINE_REPO} ${JFROG_PIPELINE_NAME} ${JFROG_RUN_NUMBER} ${JFROG_PROJECT} ${APP_URL} ${TAG_RULE}