forked from jenkinsci/JenkinsPipelineUnit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDeclarativePipelineTest.groovy
More file actions
36 lines (31 loc) · 1.57 KB
/
DeclarativePipelineTest.groovy
File metadata and controls
36 lines (31 loc) · 1.57 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
package com.lesfurets.jenkins.unit.declarative
import com.lesfurets.jenkins.unit.BasePipelineTest
import static com.lesfurets.jenkins.unit.MethodSignature.method
@groovy.transform.InheritConstructors
abstract class DeclarativePipelineTest extends BasePipelineTest {
def pipelineInterceptor = { Closure closure ->
GenericPipelineDeclaration.binding = super.binding
GenericPipelineDeclaration.createComponent(DeclarativePipeline, closure).execute(delegate)
}
@Override
void setUp() throws Exception {
super.setUp()
helper.registerAllowedMethod('booleanParam', [Map], paramInterceptor)
helper.registerAllowedMethod('checkout', [Closure])
helper.registerAllowedMethod('credentials', [String], { String credName ->
return super.binding.getVariable('credentials')[credName]
})
helper.registerAllowedMethod('cron', [String])
helper.registerAllowedMethod('input', [Closure])
helper.registerAllowedMethod('message', [String])
helper.registerAllowedMethod(method("pipeline", Closure), pipelineInterceptor)
helper.registerAllowedMethod('pollSCM', [String])
helper.registerAllowedMethod('script', [Closure])
helper.registerAllowedMethod('skipDefaultCheckout')
helper.registerAllowedMethod('string', [Map], stringInterceptor)
helper.registerAllowedMethod('timeout', [Integer, Closure])
helper.registerAllowedMethod('timestamps')
super.binding.setVariable('credentials', [:])
super.binding.setVariable('params', [:].asImmutable())
}
}