扩展Jenkins Groovy DSL [英] Extending the Jenkins Groovy DSL
问题描述
如何在我的Jenkins实例中添加/编辑新代码,以便在DSL脚本中访问?内容如下
我继承了一个Jenkins实例。这种继承的一部分包括在闹鬼的房子里度过夜晚写一些新的自动化在groovy 通过乔布斯DSL插件 。由于我害怕破坏我们的jenkins实例,我的第一步是建立一个本地开发实例。
我在本地开发实例上运行我们现有的一个 DSL脚本时遇到问题 - 我在本地服务器上的构建失败,在Jenkins错误控制台中。
处理DSL脚本jobs.groovy
错误:启动失败:
jobs.groovy:1:无法解决类thecompanysname.jenkins.extensions
有问题的脚本开始/ b>
import thecompanysname.jenkins.extensions
use(extensions){
def org ='project-name'
def project ='test-jenkins-repo'
def _email ='foo@example.com'
所以,据我所知,看起来像一个predecesor已经编写了一些自定义的Groovy代码,它们正在导入
import thecompanysname.jenkins.extensions
什么不是明白我是
- 这里代码生命
- 我可以在真正的Jenkins实例中找到它
- 我可以如何添加到我的本地实例中
欢迎提供具体答案,因为我们的是您如何学习钓鱼答案。
虽然可能有其他方法可以完成此操作, b
-
我安装的Jenkins实例具有旧版本的作业DSL插件。
-
这个版本的Jobs DSL插件允许您在 中设置额外的
classpath
处理DSL构建作业部分,该部分指向其他jar
文件。这些jar文件可以让你访问groovy脚本中的其他类(即thecompanysname.jenkins.extensions $ c $不幸的是,更新版本的 DSL插件已经将这个删除了选项,目前尚不清楚是否可以添加它。然而,这是另一个问题。
How can I add/edit new code to my Jenkins instance that would be accesible in a DSL script? Context follows
I've inherited a Jenkins instance. Part of this inheritance includes
spending the night in a haunted housewriting some new automation in groovy via the Jobs DSL plugin. Since I'm fearful of ruining our jenkins instance, my first step is setting up a local development instance.I'm having trouble running one of our existing DSL Scripts on my local development instance -- my builds on the local server fail with the following in the Jenkins error console.
Processing DSL script jobs.groovy ERROR: startup failed: jobs.groovy: 1: unable to resolve class thecompanysname.jenkins.extensions
The script in question starts off like this.
import thecompanysname.jenkins.extensions use(extensions) { def org = 'project-name' def project = 'test-jenkins-repo' def _email = 'foo@example.com'
So, as near I can tell, it seems like a predecesor has written some custom Groovy code that they're importing
import thecompanysname.jenkins.extensions
What's not clear to me is
- Where this code lives
- How I can find it in our real Jenkins instance
- How I can add to to my local instance
Specific answers are welcome, as our here's how you can learn to fish answers.
解决方案While there may be other ways to accomplish this, after a bit of poking around I discovered
The Jenkins instance I've installed has an older version of the Jobs DSL plugin installed.
This version of the Jobs DSL plugin allowed you to set an additional
classpath
in your Process DSL Builds job section that pointed to additionaljar
files.These jar files can give you access to additional classes in your groovy scripts (i.e.
thecompanysname.jenkins.extensions
)
Unfortunately, more recent versions of the Jobs DSL plugin have removed this option, and it's not clear if it's possible to add it back. That, however, is another question.
这篇关于扩展Jenkins Groovy DSL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!