3

我想从我的 DSL 脚本中访问当前正在执行的种子作业的配置。

例如,我想为我正在创建的作业使用与我的种子作业相同的 SCM 设置。

我该怎么做呢?

4

1 回答 1

3

没有内置的 DSL 方法可以做到这一点。你需要看看Jenkins API。要获取当前执行作业的 SCM 设置,请执行以下操作:

hudson.model.Executor executor = hudson.model.Executor.currentExecutor()
hudson.model.FreeStyleBuild build = executor.currentExecutable
hudson.model.FreeStyleProject project = build.project
hudson.scm.SCM scm = project.scm
于 2015-03-23T08:59:01.263 回答