Skip to content

Commit e4ede28

Browse files
authored
extend plugin to allow for Codefresh instance to resume or terminate the workflow (#539)
* extend plugin to allow for Codefresh instance to resume or terminate the workflow Update set has also been updated to reflect new logic Signed-off-by: Laurent Rochette <[email protected]> * Adding info about ServiceNow releases --------- Signed-off-by: Laurent Rochette <[email protected]>
1 parent db040b4 commit e4ede28

File tree

9 files changed

+1604
-0
lines changed

9 files changed

+1604
-0
lines changed

workflows/servicenow/assets/xml/ServiceNow-Codefresh_Integration_1.3.0.xml

Lines changed: 903 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
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+
* Tokyo
12+
13+
## Requirements
14+
1. create a secret containing 2 pieces of informations to connect to your
15+
ServiceNow instance. See [example](../../assets/sn_auth.yml)
16+
- username
17+
- password
18+
2. create a secret containing the Codefresh API Key (in the token field). See [example](../../assets/cf_token.yml)
19+
3. install the [local update](../../assets/xml/ServiceNow-Codefresh_Integration_1.3.0.xml) set in your instance
20+
21+
## Templates
22+
1. [createcr](https://github.com/codefresh-io/argo-hub/blob/main/workflows/servicenow/versions/1.3.0/docs/createcr.md)
23+
1. [updatecr](https://github.com/codefresh-io/argo-hub/blob/main/workflows/servicenow/versions/1.3.0/docs/updatecr.md)
24+
1. [closecr](https://github.com/codefresh-io/argo-hub/blob/main/workflows/servicenow/versions/1.3.0/docs/closecr.md)
25+
26+
27+
## Security
28+
29+
Minimal required permissions
30+
31+
[Full rbac permissions list](https://github.com/codefresh-io/argo-hub/blob/main/workflows/servicenow/versions/1.3.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: update-cr
29+
spec:
30+
entrypoint: main
31+
templates:
32+
- name: main
33+
dag:
34+
tasks:
35+
- name: update-sn-cr
36+
templateRef:
37+
name: argo-hub.servicenow.1.3.0
38+
template: updatecr
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: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
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+
* CF_RUNTIME (required) - name of the GtiOps Runtime
15+
* CF_URL (required for onprem) - URL of your Codefresh instance. Default is 'https://g.codefresh.io'
16+
* 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`
17+
* LOG_LEVEL (optional) - A flag to indicate log-level. Values are `info`, `debug`, `warning`, `error`, `critical`. Default value is `info`.
18+
19+
### Outputs
20+
#### Parameters
21+
* CR_SYSID: the sysid of the record created that can be use to update or close the Change Request later on
22+
* CR_NUMBER: a more human readable Change Request Number
23+
24+
## Examples
25+
26+
### createcr Example
27+
```
28+
apiVersion: argoproj.io/v1alpha1
29+
kind: Workflow
30+
metadata:
31+
generateName: create-cr
32+
spec:
33+
entrypoint: create-sn-cr
34+
templates:
35+
- name: main
36+
dag:
37+
tasks:
38+
- name: create-sn-cr
39+
templateRef:
40+
name: argo-hub.servicenow.1.3.0
41+
template: createcr
42+
arguments:
43+
parameters:
44+
- name: TOKEN
45+
value: cf-token
46+
- name: SN_INSTANCE
47+
value: "https://XXXX.service-now.com"
48+
- name: SN_AUTH
49+
value: "sn-auth"
50+
- name: CF_RUNTIME
51+
value: csdp
52+
- name: LOG_LEVEL
53+
value: debug
54+
- name: CR_DATA
55+
value: >-
56+
{"short_description": "Application deployment to QA environment",
57+
"description": "Change for build {{workflow.id}}.\nThis change was created by the ServiceNow Workflow template",
58+
"justification": "I do not need a justification\nMy app is awesome",
59+
"cmdb_ci":"tomcat"
60+
}
61+
```
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.3.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)