Skip to content

Commit 45e57f3

Browse files
authored
Issue #561 snow Standard Change Request (#562)
* New version to add Standrad change Signed-off-by: lrochette <[email protected]> * alpha version Signed-off-by: lrochette <[email protected]> * alpha version Signed-off-by: lrochette <[email protected]> * alpha version Signed-off-by: lrochette <[email protected]> * completed and tested Signed-off-by: lrochette <[email protected]> * minor Signed-off-by: lrochette <[email protected]> --------- Signed-off-by: lrochette <[email protected]>
1 parent dd12773 commit 45e57f3

File tree

9 files changed

+846
-0
lines changed

9 files changed

+846
-0
lines changed

workflows/servicenow/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## v1.4.0 (Mar 27, 2025)
4+
### Added
5+
* ability to create a Standard Change passing the template name
6+
in the `STD_CR_TEMPLATE` variable.
7+
38
## v1.3.1 (Oct 29, 2024)
49
### Changed
510
* Make CR_SYSID and CR_NUMBER global output parameters so they can be passed between pre and post actions in promotion workflows.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# ServiceNow
2+
3+
## Summary
4+
5+
A set of templates to perform operations against a ServiceNow instance.
6+
7+
### Compatibility
8+
9+
The workflowTemplate have been tested on the following instance releases:
10+
11+
* Washington DC
12+
13+
## Requirements
14+
1. Create a secret containing 2 pieces of information to connect to your
15+
ServiceNow instance. See [example](../../assets/sn_auth.yml)
16+
- username
17+
- password
18+
See the [example](../../assets/sn_auth.yml) for more details.
19+
20+
The user needs change_management permissions.
21+
22+
2. Create a secret containing the Codefresh API Key (in the token field). See
23+
the [example](../../assets/cf_token.yaml) for more details.
24+
3. install the [local update](../../assets/xml/ServiceNow-Codefresh_Integration_1.3.1.xml)
25+
set in your instance using the Retrieve Update Sets table. Check with your
26+
ServiceNow admin if you're not sure or don't have enough permissions. The
27+
architecture is detailed in this
28+
[old blog article](https://codefresh.io/blog/servicenow-integration/).
29+
30+
## Templates
31+
1. [createcr](https://github.com/codefresh-io/argo-hub/blob/main/workflows/servicenow/versions/1.4.0/docs/createcr.md) - Create a new Change Request
32+
1. [updatecr](https://github.com/codefresh-io/argo-hub/blob/main/workflows/servicenow/versions/1.4.0/docs/updatecr.md) - Modify an existing Change Request
33+
1. [closecr](https://github.com/codefresh-io/argo-hub/blob/main/workflows/servicenow/versions/1.4.0/docs/closecr.md) - Close an open Change Request
34+
35+
36+
## Security
37+
38+
Minimal required permissions
39+
40+
[Full rbac permissions list](https://github.com/codefresh-io/argo-hub/blob/main/workflows/servicenow/versions/1.4.0/rbac.yaml)
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# closecr
2+
3+
## Summary
4+
Close a Change Request on the ServiceNow instance
5+
6+
## Inputs/Outputs
7+
8+
### Inputs
9+
#### Parameters
10+
* SN_INSTANCE (required) - URL of the ServiceNow instance aka https://instance.service-now.com
11+
* SN_AUTH (required) - Secret name containing the user and password to log into the instance
12+
* CR_DATA (optional) - a string containing a JSON body to allow the modification of the Change Request in addition to closing it. The exact content is dependent on your implementation of Change Management and what fields you want to update.
13+
* CR_CLOSE_CODE (required) - Closing code. Value can be "successful", "successful_issues" or "unsuccessful". Default is "successful"
14+
* CR_CLOSE_NOTES (required) - a string to add to the closure information
15+
* CR_SYSID (required) - the sysid of the Change Request record created previously.
16+
* LOG_LEVEL (optional) - A flag to indicate log-level. Values are info, debug, warning, error, critical. Default value is info.
17+
18+
### Outputs
19+
20+
None
21+
22+
23+
### closecr Example
24+
```
25+
apiVersion: argoproj.io/v1alpha1
26+
kind: Workflow
27+
metadata:
28+
generateName: close-cr
29+
spec:
30+
entrypoint: main
31+
templates:
32+
- name: main
33+
dag:
34+
tasks:
35+
- name: close-sn-cr
36+
templateRef:
37+
name: argo-hub.servicenow.1.4.0
38+
template: closecr
39+
arguments:
40+
parameters:
41+
- name: SN_INSTANCE
42+
value: "https://XXXX.service-now.com"
43+
- name: SN_AUTH
44+
value: "sn-auth"
45+
- name: LOG_LEVEL
46+
value: info
47+
- name: CR_SYSID
48+
value: '{{ tasks.create-sn-cr.outputs.parameters.CR_SYSID}}'
49+
- name: CR_CLOSE_CODE
50+
value: "successful"
51+
- name: CR_CLOSE_NOTES
52+
value: "Closed automatically by Argo-Hub ServiceNow workflow template"
53+
54+
```
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
# createcr
2+
3+
## Summary
4+
Create a new Change Request on the ServiceNow instance
5+
6+
## Inputs/Outputs
7+
8+
### Inputs
9+
#### Parameters
10+
* TOKEN (required) - Secret name containing the Codefresh API Key
11+
* SN_INSTANCE (required) - URL of the ServiceNow instance aka https://instance.service-now.com
12+
* SN_AUTH (required) - Secret name containing the user and password to log into the instance
13+
* CR_DATA (required) - a string containing a JSON body to allow the creation of the Change Request. The exact content is dependent on your implementation of Change Management
14+
* STD_CR_TEMPLATE (optional) - name of a Standard Change template. Using this parameter will open a Standard Change (pre-approved) instead of a normal one.
15+
* CF_RUNTIME (required) - name of the GtiOps Runtime
16+
* CF_URL (required for onprem) - URL of your Codefresh instance. Default is 'https://g.codefresh.io'
17+
* CR_CONFLICT_POLICY (optional) - Policy to execute in case of schedule conflict. Accepted values are `ignore` (no check is done), `wait` (workflow will wait until the conflict is resolved) or `reject` (ServiceNow flow returns a deny answer). Default value is `ignore`
18+
* LOG_LEVEL (optional) - A flag to indicate log-level. Values are `info`, `debug`, `warning`, `error`, `critical`. Default value is `info`.
19+
20+
### Outputs
21+
#### Parameters
22+
* CR_SYSID: the sysid of the record created that can be use to update or close the Change Request later on
23+
* CR_NUMBER: a more human readable Change Request Number
24+
25+
## Examples
26+
27+
### createcr Example
28+
#### Normal Change
29+
```
30+
apiVersion: argoproj.io/v1alpha1
31+
kind: Workflow
32+
metadata:
33+
generateName: create-cr
34+
spec:
35+
entrypoint: create-sn-cr
36+
templates:
37+
- name: main
38+
dag:
39+
tasks:
40+
- name: create-sn-cr
41+
templateRef:
42+
name: argo-hub.servicenow.1.4.0
43+
template: createcr
44+
arguments:
45+
parameters:
46+
- name: TOKEN
47+
value: cf-token
48+
- name: SN_INSTANCE
49+
value: "https://XXXX.service-now.com"
50+
- name: SN_AUTH
51+
value: "sn-auth"
52+
- name: CF_RUNTIME
53+
value: csdp
54+
- name: LOG_LEVEL
55+
value: debug
56+
- name: CR_DATA
57+
value: >-
58+
{"short_description": "Application deployment to QA environment",
59+
"description": "Change for build {{workflow.id}}.\nThis change was created by the ServiceNow Workflow template",
60+
"justification": "I do not need a justification\nMy app is awesome",
61+
"cmdb_ci":"tomcat"
62+
}
63+
```
64+
65+
#### Standard Change
66+
```
67+
apiVersion: argoproj.io/v1alpha1
68+
kind: Workflow
69+
metadata:
70+
generateName: create-cr
71+
spec:
72+
entrypoint: create-sn-cr
73+
templates:
74+
- name: main
75+
dag:
76+
tasks:
77+
- name: create-sn-cr
78+
templateRef:
79+
name: argo-hub.servicenow.1.4.0
80+
template: createcr
81+
arguments:
82+
parameters:
83+
- name: TOKEN
84+
value: cf-token
85+
- name: SN_INSTANCE
86+
value: "https://XXXX.service-now.com"
87+
- name: SN_AUTH
88+
value: "sn-auth"
89+
- name: CF_RUNTIME
90+
value: demo
91+
- name: STD_CR_TEMPLATE
92+
value: "Deploy pre-approved Application"
93+
- name: CR_DATA
94+
value: >-
95+
{"short_description": "Application deployment to Staging environment",
96+
"description": "Change for build {{workflow.id}}.\nThis change was created by the ServiceNow Workflow template",
97+
"justification": "I do not need a justification\nMy app is awesome"
98+
}
99+
```
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# updatecr
2+
3+
## Summary
4+
Modify a Change Request on the ServiceNow instance
5+
6+
## Inputs/Outputs
7+
8+
### Inputs
9+
#### Parameters
10+
* SN_INSTANCE (required) - URL of the ServiceNow instance aka https://instance.service-now.com
11+
* SN_AUTH (required) - Secret name containing the user and password to log into the instance
12+
* CR_DATA (required) - a string containing a JSON body to allow the modification of the Change Request. The exact content is dependent on your implementation of Change Management and what fields you want to update.
13+
* CR_SYSID: the sysid of the Change Request record created previously.
14+
* LOG_LEVEL (optional) - A flag to indicate log-level. Values are info, debug, warning, error, critical. Default value is info.
15+
16+
### Outputs
17+
18+
None
19+
20+
21+
### updatecr Example
22+
```
23+
apiVersion: argoproj.io/v1alpha1
24+
kind: Workflow
25+
metadata:
26+
generateName: update-cr
27+
spec:
28+
entrypoint: main
29+
templates:
30+
- name: main
31+
dag:
32+
tasks:
33+
- name: update-sn-cr
34+
templateRef:
35+
name: argo-hub.servicenow.1.4.0
36+
template: updatecr
37+
arguments:
38+
parameters:
39+
- name: SN_INSTANCE
40+
value: "https://XXXX.service-now.com"
41+
- name: SN_AUTH
42+
value: "sn-auth"
43+
- name: LOG_LEVEL
44+
value: warning
45+
- name: CR_SYSID
46+
value: '{{ tasks.create-sn-cr.outputs.parameters.CR_SYSID}}'
47+
- name: CR_DATA
48+
value: '{"work_notes":"Image build with tag latest"}'
49+
```
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
FROM python:3.11.5-slim-bookworm
2+
RUN pip3 install requests
3+
4+
COPY ./snow.py /snow/snow.py
5+
ENTRYPOINT [ "python3", "/snow/snow.py" ]

0 commit comments

Comments
 (0)