You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+81Lines changed: 81 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -173,3 +173,84 @@ This specifies the sonar project key.
173
173
174
174
```
175
175
176
+
**Example of get change for ServiceNow via commandline**
177
+
```yaml
178
+
179
+
This custom step needs to be added at job level to get changeRequestNumber from ServiceNow instance with provided changeDetails to identify the change-request.
180
+
181
+
stages:
182
+
- DevOpsGetChange
183
+
184
+
ServiceNow DevOps Get Change:
185
+
stage: DevOpsGetChange
186
+
image: servicenowdocker/sndevops:4.0.0
187
+
script:
188
+
- sndevopscli get change -p "{\"buildNumber\":${CHG_JOB_ID},\"stageName\":\"ServiceNow DevOps Change Step\",\"pipelineName\":\"GitlabDockerGetAndUpdateChange\"}"
189
+
190
+
-p: It stands for changeDetails. The change details to be used for identifying change request in ServiceNow instance. The change details is a JSON object surrounded by curly braces {} containing key-value pair separated by a comma ,. A key-value pair consists of a key and a value separated by a colon :. The keys supported in key-value pair are buildNumber, pipelineName, stageName
191
+
192
+
buildNumber: [mandatory]
193
+
This specifies ID of the Job where we have created change request.
194
+
195
+
stageName: [mandatory]
196
+
This specifies the Job name where we have created change request..
197
+
198
+
pipelineName: [mandatory]
199
+
This specifies the pipeline name.
200
+
201
+
Outputs:
202
+
sndevopschg.json file created with content: {
203
+
"status": "SUCCESS",
204
+
"changeRequestNumber": "CHGXXXXX"
205
+
}
206
+
207
+
changeRequestNumber: Change Request Number found for the given change details
208
+
status: To know the status of the Change Request GET.
209
+
210
+
```
211
+
212
+
**Example of update change for ServiceNow via commandline**
213
+
```yaml
214
+
215
+
This custom step needs to be added at job level to Update change in ServiceNow instance for the changeRequestNumber provided as input along with changeRequestDetails.
216
+
217
+
stages:
218
+
- DevOpsUpdateChangeStage
219
+
220
+
ServiceNow DevOps Update Change:
221
+
stage: DevOpsUpdateChangeStage
222
+
image: servicenowdocker/sndevops:4.0.0
223
+
script:
224
+
- sndevopscli update change -n 'CHGXXXXXX' -p "{\"short_description\":\"G Venkata12345 Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"XXXXX\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}"
225
+
226
+
-n [Not mandatory if we have sndevopschg.json in our pipeline yml]: It stands for changeRequestNumber. The change request number to identify a unique change request.
227
+
Precedence of choosing changeRequestNumber:
228
+
- changeRequestNumber mentioned in the pipeline yml
229
+
- changeRequestNumber stored in sndevopschg.json.
230
+
231
+
-p : It stands for changeDetails. The change details to be used for Updating the change request information identified by the specified change request number with the key-value pairs. The change details is a JSON object surrounded by curly braces {} containing key-value pair separated by a comma ,. A key-value pair consists of a key and a value separated by a colon :. The keys supported in key-value pair are short_description, state, description, work_notes ..so on
232
+
233
+
OR
234
+
- sndevopscli update change -p "{\"short_description\":\"Updated Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"XXXXXXXXXX\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}"
235
+
236
+
NOTE: State should be specified at last in case if you are update the state of change request.
237
+
- sndevopscli update change -p "{\"short_description\":\"Updated Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"XXXXXXXXXX\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\","state":"3"}'
238
+
239
+
```
240
+
241
+
**Example to incorporate autoCloseChange feature for ServiceNow via commandline**
242
+
```yaml
243
+
244
+
stages:
245
+
- changeapproval
246
+
247
+
ServiceNow DevOps Change Step:
248
+
stage: changeapproval
249
+
image: servicenowdocker/sndevops:4.0.0
250
+
script:
251
+
- sndevopscli create change -p "{\"changeStepDetails\":{\"timeout\":3600,\"interval\":100},\"autoCloseChange\":true,\"attributes\":{\"short_description\":\"G Venkata Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"xxxxxxxx\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}}"
- sndevopscli create change -p '{"changeStepDetails":{"timeout":3600,"interval":100},"attributes":{"short_description":"Automated Software Deployment","description":"Automated Software Deployment.","assignment_group":"xxxxxx","implementation_plan":"Software update is tested and results can be found in Test Summaries Tab.","backout_plan":"When software fails in production, the previous software release will be re-deployed.","test_plan":"Testing if the software was successfully deployed or not"}}'
- sndevopscli create change -p "{\"changeStepDetails\":{\"timeout\":3600,\"interval\":100},\"autoCloseChange\":true,\"attributes\":{\"short_description\":\"G Venkata Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"a715cd759f2002002920bde8132e7018\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}}"
36
+
- sndevopscli get change #If we are placing get change cli command in the same job where we are creating change then no need to mention the changeDetails.
37
+
artifacts:
38
+
paths:
39
+
- generated_job_id.env
40
+
41
+
DevOps Get Change:
42
+
stage: getchange
43
+
script:
44
+
- source generated_job_id.env
45
+
- sndevopscli get change -p "{\"buildNumber\":${CHG_JOB_ID},\"stageName\":\"ServiceNow DevOps Change Step\",\"pipelineName\":\"SmrutiTestDemoProject\"}"
46
+
artifacts:
47
+
paths:
48
+
- sndevopschg.json
49
+
dependencies:
50
+
- ServiceNow DevOps Change Step
51
+
52
+
DevOps Update Change:
53
+
stage: updatechange
54
+
script:
55
+
#- sndevopscli update change -n 'CHGXXXX' -p "{\"short_description\":\"Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"xxxxxxx\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}"
56
+
- sndevopscli update change -p "{\"short_description\":\"Updated Automated Software Deployment\",\"description\":\"Automated Software Deployment.\",\"assignment_group\":\"xxxxxxx\",\"implementation_plan\":\"Software update is tested and results can be found in Test Summaries Tab.\",\"backout_plan\":\"When software fails in production, the previous software release will be re-deployed.\",\"test_plan\":\"Testing if the software was successfully deployed or not\"}"
thrownewError('Change request details cannot be retrieved because the ServiceNow Instance URL is invalid. Enter the correct URL and try again.');
85
+
}
86
+
87
+
elseif(err.message.includes('401')){
88
+
thrownewError('The SNOW_TOKEN and SNOW_TOOLID are incorrect. Verify that the GitLab project level variables are configured.');
89
+
}
90
+
91
+
elseif(err.message.includes('405')){
92
+
thrownewError('Change request details cannot be retrieved because response Code from ServiceNow is 405. Please check ServiceNow logs for more details.');
93
+
}
94
+
95
+
elseif(err.response.status==500){
96
+
thrownewError('Change request details cannot be retrieved because response code from ServiceNow is 500. Please check ServiceNow logs for more details.')
0 commit comments