-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpipelines.yml
124 lines (122 loc) · 5.4 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
template: true
valuesFilePath: values.yml
resources:
- name: codeRepo
type: GitRepo
configuration:
path: {{ .Values.GitHub.path }}
gitProvider: {{ .Values.GitHub.gitProvider }}
branches:
include: master
- name: dockerImage
type: Image
configuration:
registry: {{ .Values.Artifactory.intName }}
sourceRepository: {{ .Values.Artifactory.devRepo }}
imageName: {{ .Values.app.dockerImageName }}
imageTag: ${run_number}
autoPull: true
- name: buildInfo
type: Buildinfo
configuration:
sourceArtifactory: {{ .Values.Artifactory.intName }}
buildName: {{ .Values.app.buildName }}
buildNumber: ${run_number}
- name: promotedBuildInfo
type: Buildinfo
configuration:
sourceArtifactory: {{ .Values.Artifactory.intName }}
buildName: {{ .Values.app.buildName }}
buildNumber: ${run_number}
pipelines:
- name: workshop_app_build
steps:
- name: app_docker_build
type: DockerBuild
configuration:
affinityGroup: docker_build
dockerFileLocation: {{ .Values.app.dockerFileLocation }}
dockerFileName: Dockerfile
dockerImageName: {{ .Values.app.dockerImageName }}
dockerImageTag: ${run_number}
inputResources:
- name: codeRepo
integrations:
- name: {{ .Values.Artifactory.intName }}
execution:
onStart:
- cd $res_codeRepo_resourcePath
- sed "s|Num|${run_number}|g" $res_codeRepo_resourcePath/workshop-app/src/app/app.component.html > $res_codeRepo_resourcePath/workshop-app/src/app/app.component.html.update
- mv $res_codeRepo_resourcePath/workshop-app/src/app/app.component.html $res_codeRepo_resourcePath/workshop-app/src/app/app.component.html.orig
- mv $res_codeRepo_resourcePath/workshop-app/src/app/app.component.html.update $res_codeRepo_resourcePath/workshop-app/src/app/app.component.html
onSuccess:
- echo "Congrats the Docker image was built!"
- send_notification int_pagerduty_token --routingkey {{ .Values.PagerDuty.pipelinesRoutingKey }} --text "Docker image built {{ .Values.app.dockerImageName }} Tag ${run_number}"
- name: app_docker_push
type: DockerPush
configuration:
affinityGroup: docker_build
autoPublishBuildInfo: true
forceXrayScan: true
targetRepository: {{ .Values.Artifactory.devRepo }}
integrations:
- name: {{ .Values.Artifactory.intName }}
inputSteps:
- name: app_docker_build
outputResources:
- name: dockerImage
- name: buildInfo
execution:
onSuccess:
- echo "Congrats the Docker image was pushed!"
- send_notification {{ .Values.PagerDuty.intName }} --routingkey {{ .Values.PagerDuty.pipelinesRoutingKey }} --text "Docker image pushed to dev repo {{ .Values.app.dockerImageName }} Tag ${run_number}"
- name: publish_build_info
type: PublishBuildInfo
configuration:
inputSteps:
- name: app_docker_push
outputResources:
- name: buildInfo
- name: app_promote
type: PromoteBuild
configuration:
targetRepository: {{ .Values.Artifactory.prodRepo }}
includeDependencies: true
status: Passed
comment: Artifact passed Xray Scan
copy: true
inputResources:
- name: buildInfo
outputResources:
- name: promotedBuildInfo
execution:
onSuccess:
- echo "Congrats the Docker image was promoted!"
- send_notification {{ .Values.PagerDuty.intName }} --routingkey {{ .Values.PagerDuty.pipelinesRoutingKey }} --text "Docker image was promoted to the prod repo {{ .Values.app.dockerImageName }} Tag ${run_number}"
- name: deploy
type: Bash
configuration:
integrations:
- name: {{ .Values.AWS.intName }}
- name: {{ .Values.AWS.eks }}
inputResources:
- name: codeRepo
inputSteps:
- name: app_promote
execution:
onExecute:
- cd $res_codeRepo_resourcePath
- pwd
- ls
- curl -o aws-iam-authenticator https://amazon-eks.s3.us-west-2.amazonaws.com/1.19.6/2021-01-05/bin/linux/amd64/aws-iam-authenticator
- chmod +x ./aws-iam-authenticator
- mkdir -p $HOME/bin && cp ./aws-iam-authenticator $HOME/bin/aws-iam-authenticator && export PATH=$PATH:$HOME/bin
- sed "s|imageName|{{ .Values.app.dockerImageName }}:${run_number}|g" workshop-app/deployment.yml > my-deployment.yaml
- cat my-deployment.yaml
- kubectl apply -f my-deployment.yaml --namespace workshop
- while [ -z "$url" ]; do url=$(kubectl describe service workshop-app --namespace workshop | grep 'LoadBalancer Ingress:' | awk '{printf "https://%s",$3;}'); sleep 2; done
- echo "$url"
- echo "Workshop App launched!"
onSuccess:
- echo "Congrats the Docker image was deployed!"
- send_notification {{ .Values.PagerDuty.intName }} --routingkey {{ .Values.PagerDuty.pipelinesRoutingKey }} --text "Docker image was deployed to prod {{ .Values.app.dockerImageName }} Tag ${run_number}"