forked from electric-cloud/DSL-Samples
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathManualTaskUploadDoc.groovy
91 lines (77 loc) · 2.47 KB
/
ManualTaskUploadDoc.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
/*
Cloudbees CD/RO DSL: Use manually uploaded documents in a pipeline
This example illustrates how manually uploaded documents (such as log files or test reports) can be used in a pipeline.
Installation
- Run this DSL code from the DSLIDE
Usage
- Navigate to Artifact management
- Create an artifact
- Upload a file to that artifact location
- Run the pipeline
- When prompted, use the parameters to select the uploaded artifact version
- Select "Completed" and [OK] to allow the pipeline to continue
- Note the following step retrieves the artifact version
*/
project "DSL-Samples",{
pipeline 'Upload user documents', {
stage 'Stage 1', {
colorCode = '#289ce1'
task 'Upload docs', {
instruction = 'Go to Artifact management and upload your document, then use the parameters to select that document.'
notificationEnabled = '1'
notificationTemplate = 'ec_default_pipeline_manual_task_notification_template'
subproject = 'DSL-Samples'
taskType = 'MANUAL'
approver = [
'Everyone',
]
formalParameter 'ArtName', {
optionsDsl = '''\
import com.electriccloud.domain.FormalParameterOptionsResult
def options = new FormalParameterOptionsResult()
getArtifacts().each { art ->
options.add(art.artifactName, art.artifactName)
}
return options
'''.stripIndent()
orderIndex = '1'
required = '1'
type = 'select'
}
formalParameter 'ArtVer', {
dependsOn = 'ArtName'
optionsDsl = '''\
def options = new FormalParameterOptionsResult()
String artName = args.parameters["ArtName"]
if (artName) {
getArtifactVersions(artifactName: args.parameters["ArtName"]).each { ver ->
options.add(ver.version, ver.version)
}
} else {
getArtifactVersions().each { ver ->
options.add(ver.version, ver.version)
}
}
return options
'''.stripIndent()
orderIndex = '2'
required = '1'
type = 'select'
}
}
task 'Retrieve the document', {
taskType = 'PLUGIN'
subpluginKey = 'EC-Artifact'
subprocedure = 'Retrieve'
actualParameter = [
artifactName: '$[/myStageRuntime/tasks[Upload docs][ArtName]]',
artifactVersionLocationProperty: '/myJob/retrievedArtifactVersions/$[assignedResourceName]',
filterList: '',
overwrite: 'update',
retrieveToDirectory: '',
versionRange: '$[/myStageRuntime/tasks[Upload docs][ArtVer]]',
]
}
}
}
}