forked from lachie83/croc-hunter
-
Notifications
You must be signed in to change notification settings - Fork 45
/
codefresh.yml
185 lines (185 loc) · 7.48 KB
/
codefresh.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
version: '1.0'
steps:
BuildingDockerImage:
title: Building Docker Image
type: build
image_name: oscon18/crochunter
working_directory: ./
dockerfile: Dockerfile
tag: '${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}'
build_arguments:
- VCS_REF=${{CF_SHORT_REVISION}}
PushingDockerImage:
title: Promote to Artifactory
type: push
candidate: ${{BuildingDockerImage}}
image_name: oscon18/crochunter
tag: '${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}'
registry: jfrog-jd-art
PackageHelmChart:
image: devth/helm
commands:
- cf_export PACKAGE=$(helm package ./charts/croc-hunter | cut -d " " -f 8)
Deploy_with_Helm:
image: codefresh/cfstep-helm:2.9.0
when:
branch:
only:
- master
environment:
- custom_imageTag=${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}
- custom_commit_sha=${{CF_SHORT_REVISION}}
- custom_imagePullSecrets_username=${{REPO_USER}}
- custom_imagePullSecrets_password=${{REPO_PASS}}
- custom_imagePullSecrets_repository=${{REPOSITORY}}
- custom_imagePullSecrets_email=${{REPO_EMAIL}}
- custom_image=jfrogjd-crochunter.jfrog.io/oscon18/crochunter
- custom_ingress_hostname=${{INGRESS_HOSTNAME}}
on_success:
metadata:
set:
- '${{BuildingDockerImage.imageId}}':
- DEPLOYED_TO_AZURE_AKS: true
Deploy_with_Helm_Dev:
image: codefresh/cfstep-helm:2.9.0
when:
branch:
only:
- dev
environment:
- CMD_PS=--dry-run
- custom_imageTag=${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}
- custom_commit_sha=${{CF_SHORT_REVISION}}
- custom_imagePullSecrets_username=${{REPO_USER}}
- custom_imagePullSecrets_password=${{REPO_PASS}}
- custom_imagePullSecrets_repository=${{REPOSITORY}}
- custom_imagePullSecrets_email=${{REPO_EMAIL}}
- custom_image=jfrogjd-crochunter.jfrog.io/oscon18/crochunter
- custom_ingress_hostname=${{INGRESS_HOSTNAME}}
BuildingTestDockerImage:
title: Building Test Docker Image
type: build
image_name: jldeen/crochunter-tests
working_directory: ./tests/
dockerfile: Dockerfile
tag: '${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}'
Deployment_Verification_Tests:
title: Running Selenium DVTs
type: composition
composition:
version: '2'
services:
selenium_hub:
image: selenium/hub:latest
ports:
- 4444
environment:
- SE_OPTS=-debug
- GRID_MAX_SESSION=5
chrome_node:
image: selenium/node-chrome:latest
ports:
- 5900
- 5555
command: bash -c "sleep 5 && /opt/bin/entry_point.sh"
depends_on:
- selenium_hub
environment:
- HUB_HOST=selenium_hub
- REMOTE_HOST=http://chrome_node:5555
- NODE_MAX_SESSION=5
- NODE_MAX_INSTANCES=5
firefox_node:
image: selenium/node-firefox:latest
user: 1000:1000
ports:
- 5900
- 5555
command: bash -c "sleep 5 && /opt/bin/entry_point.sh"
depends_on:
- selenium_hub
environment:
- HUB_HOST=selenium_hub
- REMOTE_HOST=http://firefox_node:5555
- NODE_MAX_SESSION=5
- NODE_MAX_INSTANCES=5
composition_candidates:
test:
image: ${{BuildingTestDockerImage}}
working_dir: ${{CF_VOLUME_PATH}}/${{CF_REPO_NAME}}
environment:
CF_SHORT_REVISION: ${{CF_SHORT_REVISION}}
INGRESS_HOSTNAME: ${{INGRESS_HOSTNAME}}
RELEASE_NAME: ${{RELEASE_NAME}}
command: bash -c 'IFS=" " read -a browserarray <<< "${{BROWSERS}}" && for browser in "$${browserarray[@]}"; do BROWSER=$$browser python -m pytest -vvv --html=./${{CF_BUILD_ID}}-selenium-report-$${browser}.html --self-contained-html ./tests/selenium/test_app.py; done'
volumes:
- '${{CF_VOLUME_NAME}}:/codefresh/volume'
add_flow_volume_to_composition: true
on_success:
metadata:
set:
- '${{BuildingTestDockerImage.imageId}}':
- SELENIUM_DVTS: true
on_fail:
metadata:
set:
- '${{BuildingTestDockerImage.imageId}}':
- SELENIUM_DVTS: false
when:
branch:
only:
- master
PushBuildInfoAndArtifactsToArtifactory:
title: Updating Artifactory with Codefresh Build Information and Artifacts
type: composition
composition:
version: '2'
services:
buildimage:
image: ${{BuildingDockerImage}}
command: sh -c "exit 0"
composition_candidates:
scan_service:
image: codefresh/docker-jfrog-cli-go:initial-branch-c6eeb5c
working_dir: ${{CF_VOLUME_PATH}}/${{CF_REPO_NAME}}
environment:
- JFROG_CLI_OFFER_CONFIG=false
command: >
bash -c '
docker login --username ${{REPO_USER}} --password "${{REPO_PASS}}" ${{REPOSITORY}} &&
jfrog rt build-collect-env ${{CF_REPO_NAME}} ${{CF_BUILD_ID}} &&
jfrog rt build-add-git ${{CF_REPO_NAME}} ${{CF_BUILD_ID}} &&
jfrog rt config jfrogjd --url="https://jfrogjd.jfrog.io/jfrogjd" --user=${{REPO_USER}} --password="${{REPO_PASS}}" &&
jfrog rt docker-push --server-id=jfrogjd --build-name=${{CF_REPO_NAME}} --build-number=${{CF_BUILD_ID}} "${{REPOSITORY}}/oscon18/crochunter:${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}" crochunter &&
jfrog rt upload --server-id=jfrogjd --build-name=${{CF_REPO_NAME}} --build-number=${{CF_BUILD_ID}} "$PACKAGE" helm-repo &&
jfrog rt upload --server-id=jfrogjd --build-name=${{CF_REPO_NAME}} --build-number=${{CF_BUILD_ID}} "*.html" codefresh-build-artifacts &&
codefresh auth create-context --api-key ${{CODEFRESH_CLI_KEY}} &&
jfrog rt build-publish --server-id=jfrogjd --build-url="${{CF_BUILD_URL}}" --env-exclude="*key*;*pass*;" ${{CF_REPO_NAME}} ${{CF_BUILD_ID}} |& tee publish.txt &&
codefresh annotate image $$(docker images -q "${{REPOSITORY}}/oscon18/crochunter:${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}")
--label JF_BUILD="$$(sed -n "s/^.*http/http/p" publish.txt)" &&
jfrog rt build-scan --server-id=jfrogjd ${{CF_REPO_NAME}} ${{CF_BUILD_ID}} | tee results.json &&
codefresh annotate image $$(docker images -q "${{REPOSITORY}}/oscon18/crochunter:${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}")
--label JF_XRAY_ALERTS="$$(jq ".summary.total_alerts" results.json)"
--label JF_XRAY_MSG="$$(jq ".summary.message" results.json)"
--label JF_XRAY_RPT="https://jfrogjd-xray.jfrog.io/web/#/component/details/docker:~2F~2Foscon18~2Fcrochunter/${{CF_BRANCH_TAG_NORMALIZED}}-${{CF_SHORT_REVISION}}" &&
if [[ "$$(jq ".summary.fail_build" results.json)" = *true* ]]; then exit 1; else exit 0; fi
'
depends_on:
- buildimage
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /var/lib/docker:/var/lib/docker
- '${{CF_VOLUME_NAME}}:/codefresh/volume'
add_flow_volume_to_composition: true
on_success:
metadata:
set:
- '${{BuildingDockerImage.imageId}}':
- JFROG_XRAY_SCAN: true
- CF_QUALITY: true
on_fail:
metadata:
set:
- '${{BuildingDockerImage.imageId}}':
- JFROG_XRAY_SCAN: false
- CF_QUALITY: false