forked from electric-cloud/DSL-Samples
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathWaitForAttachedPipelines.groovy
More file actions
118 lines (110 loc) · 3.37 KB
/
Copy pathWaitForAttachedPipelines.groovy
File metadata and controls
118 lines (110 loc) · 3.37 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
Wait for attached pipelines to complete before advancing release
Instructions
- Apply this DSL by cutting and pasting to the DSLIDE or by running
ectool evalDsl --dslFile WaitForAttachedPipelines.groovy
- Navigate the the running release, note that QA is waiting
- Navigate to the Release Portfolio list
- Open each of the attached pipeline runs and do the approval so the pipelines continue
- The release should continue now
What this DSL does
- Creates two pipelines
- Creates a Release
- Runs the pipelines
- Attaches them to the release
- Starts the release and runs it
- The release is configured so that the QA stage will only start once the attached pipelines have completed
*/
project "DSL-Samples",{
release "The release",{
pipeline "The release pipeline",{
stage "Dev",{
task 'Promote code', {
taskType = 'COMMAND'
actualParameter = [
commandToRun: 'echo promoting',
]
}
}
stage "QA",{
precondition = '''\
$[/javascript
var attachedRuns = api.getAttachedPipelineRuns(
{
projectName: myRelease.projectName,
releaseName: myRelease.releaseName
}
).attachedPipelineRunDetail
var allCompleted=true
if (typeof(attachedRuns)!=='undefined')
for (i=0; i < attachedRuns.length; i++) {
var isCompleted = api.getProperty(
{
flowRuntimeId: attachedRuns[i].flowRuntimeId,
propertyName: "/myPipelineRuntime/completed"
}
).property.value
if (isCompleted=="false") allCompleted=false
}
setProperty("/myPipelineRuntime/allCompleted",allCompleted)
allCompleted?"true":"false"
]
'''.stripIndent()
task 'Run tests', {
precondition = '' // workaround for rogue inherritance (to be fixed post v10.1)
taskType = 'COMMAND'
actualParameter = [
commandToRun: 'echo testing',
]
}
}
stage "UAT",{
task 'User testing', {
taskType = 'COMMAND'
actualParameter = [
commandToRun: 'echo user testing',
]
}
}
stage "PROD",{
task 'Production deployment', {
taskType = 'COMMAND'
actualParameter = [
commandToRun: 'echo deploying to production',
]
}
}
}
}
pipeline "Component A",{
stage "Merge to Main",{
gate 'POST', {
task 'Approve for release', {
taskType = 'APPROVAL'
approver = [
'Everyone',
]
}
}
}
}
pipeline "Component B",{
stage "Merge to Main",{
gate 'POST', {
task 'Approve for release', {
taskType = 'APPROVAL'
approver = [
'Everyone',
]
}
}
}
}
}
def A=runPipeline(projectName: "DSL-Samples", pipelineName: "Component A").flowRuntimeId
B=runPipeline(projectName: "DSL-Samples", pipelineName: "Component B").flowRuntimeId
runPipeline projectName: "DSL-Samples", pipelineName: "The release pipeline", releaseName: "The release"
attachPipelineRun projectName: "DSL-Samples", releaseName: "The release", flowRuntimeId: A
attachPipelineRun projectName: "DSL-Samples", releaseName: "The release", flowRuntimeId: B
startRelease projectName: "DSL-Samples", releaseName: "The release"
runPipeline projectName: "DSL-Samples", pipelineName: "The release pipeline", releaseName: "The release"