我想从我的 DSL 脚本中访问当前正在执行的种子作业的配置。
例如,我想对正在创建的作业使用与种子作业相同的 SCM 设置。
我该怎么做?
最佳答案
没有内置的 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
关于jenkins-job-dsl - 在 Jenkins DSL 中获取当前配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29200502/