如何在Groovy中导入jenkins-api? [英] How to import the jenkins-api in Groovy?
问题描述
我有一个要编辑的小型groovy脚本,并且Groovy中的依赖项管理存在问题.我是groovy的新手,如果这个问题有点studip/容易回答,请提前抱歉.
我将IntelliJ
用作IDEA.
I have a small groovy script that I want to edit and I have issues with the dependency management in Groovy. I am new to groovy and sorry in advance if this question is kinda studip / easy to answer.
I use IntelliJ
as IDEA.
@Grab(group='org.jenkins-ci.main', module='jenkins-core', version='2.167', scope='provided')
//import jenkins...
def call()
{
Jenkins.instance.getItemByFullName(currentBuild.fullProjectName).getBuilds().each{ build ->
if (currentBuild.number > build.number && exec != null)
{
build.rawBuild.doKill()
}
}
}
我尝试使用 jenkins-core 依赖关系以获取代码的自动完成,文档等等信息,但是它根本不起作用.我还尝试了pom
中的maven依赖关系,但两者都没有作用.
I try to use the jenkins-core dependency to get the autocomple of the code, documentation etc. etc. for the code but it simply does not work. I also tried the maven dependency in the pom
it does work neither.
现在问我一个问题:如何在Groovy中正确导入Jenkins的依赖关系?
So now to my question: How do I import the dependency of Jenkins correctly in Groovy?
推荐答案
您可以从jenkins-ci maven回购中获得此依赖项:
You can get this dependency from jenkins-ci maven repo:
@GrabResolver(name='jenkins', root='http://repo.jenkins-ci.org/public/')
@Grab(group='org.jenkins-ci.main', module='jenkins-core', version='2.167')
这篇关于如何在Groovy中导入jenkins-api?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!