forked from DevOpsManiac/CorpSite
-
Notifications
You must be signed in to change notification settings - Fork 1
/
codefresh_sn.yaml
120 lines (109 loc) · 3.02 KB
/
codefresh_sn.yaml
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
version: "1.0"
stages:
- "clone"
- "build"
- deploy
- "test"
- post
steps:
build:
title: "Building App"
image: "codefresh/cli"
stage: "build"
commands:
- echo "Building App"
calculateDate:
image: ubuntu:latest
stage: deploy
commands:
- |
START_DATE=`date -u '+%Y-%m-%d %H:%M:%S'`
END_DATE=`date -u -d '+1 day' '+%Y-%m-%d %H:%M:%S'`
echo START_DATE=\"$START_DATE\" >> ${{CF_VOLUME_PATH}}/env_vars_to_export
echo END_DATE=\"$END_DATE\" >> ${{CF_VOLUME_PATH}}/env_vars_to_export
createCR:
type: service-now:${{VERSION}}
title: Create Service Now Change Request
stage: deploy
arguments:
CR_ACTION: createCR
SN_USER: admin
SN_PASSWORD: '${{SN_PASSWORD}}'
SN_INSTANCE: ${{SN_INSTANCE}}
TOKEN: ${{CF_TOKEN}}
CR_CONFLICT_POLICY: ignore
CR_DATA: >-
{
"short_description": "Application deployment to Prod",
"description": "Change for build ${{CF_BUILD_ID}}\nThis change was created by the Codefresh plugin",
"justification": "I do not need a justification\nMy app is awesome",
"cmdb_ci":"tomcat",
"start_date":${{START_DATE}},
"end_date":${{END_DATE}}
}
approval:
stage: deploy
description: "Approval to deploy to PROD"
type: pending-approval
timeout:
duration: 2
finalState: denied
modifyCR:
stage: deploy
title: "Modify the implementation plan"
type: service-now:${{VERSION}}
fail_fast: false
arguments:
CR_ACTION: updateCR
CR_SYSID: ${{CR_SYSID}}
SN_USER: admin
SN_PASSWORD: '${{SN_PASSWORD}}'
SN_INSTANCE: ${{SN_INSTANCE}}
CR_DATA: '{"implementation_plan":"The implementation has been approved."}'
deploy:
title: "Deploying App"
image: "codefresh/cli"
stage: "deploy"
commands:
- echo "Deploying App"
- sleep 5
test:
title: "Testing App"
image: "codefresh/cli"
stage: "test"
commands:
- echo "Testing App"
- sleep 10
modifyTestPlan:
stage: test
title: "Modify the test plan"
type: service-now:${{VERSION}}
fail_fast: false
arguments:
CR_ACTION: updateCR
CR_SYSID: ${{CR_SYSID}}
SN_USER: admin
SN_PASSWORD: '${{SN_PASSWORD}}'
SN_INSTANCE: ${{SN_INSTANCE}}
CR_DATA: '{"test_plan":"The testing suit has passed."}'
wait2:
stage: post
title: are we ready to close?
type: pending-approval
timeout:
duration: 10
timeUnit: minutes
finalState: approved
closeCR:
type: service-now:${{VERSION}}
title: Close Service Now Change Request
stage: post
arguments:
CR_ACTION: closeCR
CR_SYSID: ${{CR_SYSID}}
SN_USER: admin
SN_PASSWORD: '${{SN_PASSWORD}}'
SN_INSTANCE: ${{SN_INSTANCE}}
CR_CLOSE_CODE: "successful"
CR_CLOSE_NOTES: "Closed automatically by Codefresh build ${{CF_BUILD_ID}}"
CR_DATA: '{"work_notes":"this is a message for the work notes"}'