This repository was archived by the owner on Jun 7, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 17
Expand file tree
/
Copy pathdateTriggeredPipeline.groovy
More file actions
executable file
·98 lines (80 loc) · 3.61 KB
/
Copy pathdateTriggeredPipeline.groovy
File metadata and controls
executable file
·98 lines (80 loc) · 3.61 KB
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
/*
Format: Electric Flow DSL
File: dateTriggeredPipeline.groovy
Description: Simple pipeline with SMS notification
Model Details
-------------
- A 2-stage pipeline, Dev and QA
- An entry gate to QA
- Pipeline parameters for time and date to trigger Dev to QA promotion
- Task in Dev stage to create a schedule
- Schedule calls a procedure when its time has been reached
- The procedure triggers the gate to QA then deletes the schedule
Command-line run instructions
-----------------------------
ectool evalDsl --dslFile dateTriggeredPipeline.groovy
Instructions
------------
Run the pipeline and enter the date & time when prompted
*/
def proj = "Default"
def pipe = "Schedule Triggered Pipeline"
project proj, {
// Procedure to trigger the pipeline gate
procedure "Trigger Pipeline Gate", description: "Trigger a pipeline gate", {
formalParameter "flowRuntimeId", required: "true"
formalParameter "stageName", required: "true"
formalParameter "taskName", required: "true"
formalParameter "gateType", required: "true", // PRE | POST
description: "PRE or POST"
formalParameter "action", required: "true", // approve | reject
description: "approve or reject"
formalParameter "evidence", default: 'Triggered by $[/myJob]'
step "Trigger",
command: 'ectool completeManualTask "$[flowRuntimeId]" "$[stageName]" "$[taskName]" --actualParameter action="$[action]" evidence="$[evidence]" --gateType "$[gateType]"'
step "Delete Schedule",
command: "ectool deleteSchedule \"$projectName\" \"\$[/mySchedule]\" "
}
procedure "Create Schedule", description: "Create a schedule that runs a procedure at a particular time and date", {
formalParameter "date", required: "true", description: "Date format: yyyy-mm-dd"
formalParameter "time", required: "true", description: "Time format: hh:mm"
step "Create Schedule",
command: "ectool createSchedule \"$projectName\" " +
'"$[/myPipelineRuntime]" ' +
'--beginDate "$[date]" ' +
'--startTime "$[time]" ' +
'--procedureName "Trigger Pipeline Gate" ' +
'--actualParameter ' +
'stageName=QA ' +
'taskName="Entry Approval" ' +
'gateType="PRE" ' +
'action="approve" ' +
'evidence="Promoted by job $[/myJob]" ' +
'flowRuntimeId="$[/myPipelineRuntime/flowRuntimeId]" '
step "Create Link",
command: """\
ectool setProperty "/myPipelineStageRuntime/ec_summary/QA Schedule" --value '<html><pre>\$[date] - \$[time] UTC\n<a href=" /commander/link/editSchedule/projects/$projectName/schedules/\$[/myPipelineRuntime]">Definition</a></pre></html>'
""".stripIndent()
}
pipeline pipe, description: "Two stage pipeline with entry gate to second stage, QA", {
formalParameter "date", defaultValue: '$[/javascript var now = new Date();((now.getFullYear())+"-"+(now.getMonth()+1))+"-"+(now.getDate())]', description: "Date format: yyyy-mm-dd"
// Default value now + 30 sec
// Insert 0 in minutes and seconds if single digit
formalParameter "time", defaultValue: '$[/javascript var tt = new Date(Date.now()+30000);tt.getHours()+":"+(tt.getMinutes()).toString().replace(/^(\\d)$/, "0$1")+":"+(tt.getSeconds()).toString().replace(/^(\\d)$/, "0$1")]', description: "Time format: hh:mm:ss"
stage "Dev", {
task "Create Schedule",
taskType: 'PROCEDURE',
subproject: projectName,
subprocedure: "Create Schedule",
actualParameter: [
date: '$[date]',
time: '$[time]'
]
} // Dev
stage "QA", {
task "Entry Approval",
taskType: "APPROVAL",
gateType: "PRE"
} // QA
} // Pipeline
} // Project