How to import the jenkins-api in Groovy?

天大地大妈咪最大 提交于 2019-12-31 02:32:06

问题


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()
        }
    }
}

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.

So now to my question: How do I import the dependency of Jenkins correctly in Groovy?


回答1:


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')


来源:https://stackoverflow.com/questions/55016767/how-to-import-the-jenkins-api-in-groovy

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!