Gradle从Job-DSL-Plugin生成XML
是否有人设置了Gradle构建以在本地生成工作DSL XML?
- 在本地系统上运行DSL脚本(请参阅 user-power-moves )
- 添加到gradle(请参阅 ide-support ),
所以我为作业和插件依赖性添加了一个源。这样我就可以在课堂上构建开槽。现在,我认为我想添加一个我链接到编译或测试的执行任务,该任务与以下内容相等,但我不确定做到这一点的最佳方法。
我已经可以通过ClassPath(从理论上)访问JAR,因此我应该能够轻松地构建
curl -O https://repo.jenkins-ci.org/public/org/jenkins-ci/plugins/job-dsl-core/@version@/job-dsl-core-@[email protected]
java -jar job-dsl-core-@[email protected] sample.dsl.groovy
构建。
sourceSets {
...
jobs {
groovy {
srcDirs 'jenkins-job-dsl'
compileClasspath += main.compileClasspath
}
}
}
dependencies {
...
compile "org.jenkins-ci.plugins:job-dsl-core:$version"
}
task buildOneUsingClassFile(type: JavaExec) {
group = "Execution"
classpath = sourceSets.jobs.runtimeClasspath + sourceSets.jobs.compileClasspath
main = 'my_pipeline_dsl_job_class_name'
}
task generateDSLXml(type: JavaExec) {
group = "Execution"
description = "generate all found groovy dsl files"
classpath = sourceSets.jobs.compileClasspath
main = 'javaposse.jobdsl.Run'
args sourceSets.jobs.groovy
.filter { it.path.endsWith('.groovy') }
.collect {it.path.toString() }
.unique()
}
以上主要有效,除了我看到在Jenkins本身上有效的失败,即使具有相同的版本。但是,我在
Has anyone setup a gradle build to generate Jobs DSL xml locally?
- Run a DSL Script on a local system (see User-Power-Moves)
- Adding to gradle (see IDE-support)
So I added a sourceSet for jobs and the plugin dependency. So I can build the groovy into classes. Now I think I want to add an execution task that I link to compile or maybe test that generates in a gradle equivalent to the following but I'm not quite sure of the best way to do this.
I have access to the jar already via classpath (in theory) so I should be able to exec easily
curl -O https://repo.jenkins-ci.org/public/org/jenkins-ci/plugins/job-dsl-core/@version@/job-dsl-core-@[email protected]
java -jar job-dsl-core-@[email protected] sample.dsl.groovy
build.gradle
sourceSets {
...
jobs {
groovy {
srcDirs 'jenkins-job-dsl'
compileClasspath += main.compileClasspath
}
}
}
dependencies {
...
compile "org.jenkins-ci.plugins:job-dsl-core:$version"
}
task buildOneUsingClassFile(type: JavaExec) {
group = "Execution"
classpath = sourceSets.jobs.runtimeClasspath + sourceSets.jobs.compileClasspath
main = 'my_pipeline_dsl_job_class_name'
}
task generateDSLXml(type: JavaExec) {
group = "Execution"
description = "generate all found groovy dsl files"
classpath = sourceSets.jobs.compileClasspath
main = 'javaposse.jobdsl.Run'
args sourceSets.jobs.groovy
.filter { it.path.endsWith('.groovy') }
.collect {it.path.toString() }
.unique()
}
The above mostly works, except that I see failures that work on jenkins itself even with the same version. However, I see those same failures on https://job-dsl.herokuapp.com/ too so they may represent a different issue
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
gradle
Job DSL多分支和多个分支的缺少方法问题,
我们应该能够使用
此问题失败的方法错误。当我们重构发现这里-dsl.herokuapp.com/“ rel =“ nofollow noreferrer”> dsl playground 和通过gradle
Gradle
Job DSL multi branch and missing method problems
For multi branch we should be able to use
However this fails with a missing method error. When we refactor thus found here, generation works on dsl playground and via gradle