forked from electric-cloud-community/DSL-Samples
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPollServiceNow.groovy
177 lines (145 loc) · 4.27 KB
/
PollServiceNow.groovy
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
/*
Procedure that calls workflow which polls ServiceNow record until it reaches 'approved' state
Add PollServiceNow project to ServiceNow plugin project ACL
Install and promote WorkflowWrapper: https://github.com/electric-cloud/ec-workflow-wrapper/blob/master/out/WorkflowWrapper-1.2.0.jar
*/
project 'PollServiceNow', {
resourceName = null
workspaceName = null
procedure 'sleep', {
description = ''
jobNameTemplate = ''
resourceName = ''
timeLimit = ''
timeLimitUnits = 'minutes'
workspaceName = ''
formalParameter 'SleepTime', defaultValue: '5', {
description = 'In Second'
expansionDeferred = '0'
label = null
orderIndex = null
required = '1'
type = 'entry'
}
step 'sleep', {
description = ''
alwaysRun = '0'
broadcast = '0'
command = 'sleep $[SleepTime]'
condition = ''
errorHandling = 'failProcedure'
exclusiveMode = 'none'
logFileName = ''
parallel = '0'
postProcessor = ''
precondition = ''
releaseMode = 'none'
resourceName = ''
shell = 'ec-perl'
subprocedure = null
subproject = null
timeLimit = ''
timeLimitUnits = 'minutes'
workingDirectory = ''
workspaceName = ''
}
// Custom properties
property 'ec_customEditorData', {
// Custom properties
property 'parameters', {
// Custom properties
property 'SleepTime', {
// Custom properties
formType = 'standard'
}
}
}
}
workflowDefinition 'Wait for Approval', {
description = ''
workflowNameTemplate = ''
stateDefinition 'Start', {
description = ''
startable = '1'
subprocedure = 'GetRecord'
subproject = '/plugins/EC-ServiceNow/project'
substartingState = ''
subworkflowDefinition = ''
actualParameter 'config_name', '$[Config]'
actualParameter 'filter', ''
actualParameter 'property_sheet', '/myWorkflow'
actualParameter 'record_id', '$[RecordID]'
formalParameter 'Config', defaultValue: 'ServiceNow', {
description = 'ServiceNow configuration'
expansionDeferred = '0'
label = null
orderIndex = null
required = '1'
type = 'entry'
}
formalParameter 'RecordID', defaultValue: '', {
description = ''
expansionDeferred = '0'
label = null
orderIndex = null
required = '1'
type = 'entry'
}
// Custom properties
property 'ec_customEditorData', {
// Custom properties
property 'parameters', {
// Custom properties
property 'Config', {
// Custom properties
formType = 'standard'
}
property 'RecordID', {
// Custom properties
formType = 'standard'
}
}
}
}
stateDefinition 'Done', {
description = ''
startable = '0'
subprocedure = null
subproject = null
substartingState = null
subworkflowDefinition = null
}
stateDefinition 'Wait', {
description = ''
startable = '0'
subprocedure = 'sleep'
subproject = ''
substartingState = ''
subworkflowDefinition = ''
actualParameter 'SleepTime', '5'
}
transitionDefinition 'Done', {
description = ''
condition = '$[/javascript JSON.parse(myWorkflow.ResponseContent)[0].approval == "approved" ]'
stateDefinitionName = 'Start'
targetState = 'Done'
trigger = 'onCompletion'
}
transitionDefinition 'Wait', {
description = ''
condition = '$[/javascript JSON.parse(myWorkflow.ResponseContent)[0].approval != "approved" ]'
stateDefinitionName = 'Start'
targetState = 'Wait'
trigger = 'onCompletion'
}
transitionDefinition 'repeat', {
description = ''
condition = ''
stateDefinitionName = 'Wait'
targetState = 'Start'
trigger = 'onCompletion'
actualParameter 'Config', '$[/myWorkflow/Config]'
actualParameter 'RecordID', '$[/myWorkflow/RecordID]'
}
}
}