Ant*_*yah 6 groovy jenkins kotlin
我正在编写一些用于生成 Jenkins 作业的代码,并且使用 Kotlin 作为生成 Jenkins 作业的逻辑。我使用的 Jenkins 插件是Jenkins Job DSL插件,它是用 Groovy 编写的,用于生成作业。definition
由于不知道如何创建适当的 groovy.lang.Closure 对象,因此从 Kotlin 代码调用 Groovy 代码时设置参数时遇到问题。
这是我的 Kotlin 代码:
val pipelineJob = dslFactory.pipelineJob("my-job")
// pipelineJob.definition(JOB_DEFINITION_GOES_HERE) <-- this is the part I can't figure out
Run Code Online (Sandbox Code Playgroud)
以下是 Groovy 中的代码,我尝试将其移植到 Kotlin 中:
dslFactory.pipelineJob("my-job").with {
definition {
cps {
script("deleteDir()")
sandbox()
}
}
}
Run Code Online (Sandbox Code Playgroud)
这是我调用的方法的定义:
void definition(@DslContext(WorkflowDefinitionContext) Closure definitionClosure) {
Run Code Online (Sandbox Code Playgroud)
其他链接: DslFactory
归档时间: |
|
查看次数: |
593 次 |
最近记录: |