Issue
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?
Solution
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')
Answered By - Evgeny Smirnov
Answer Checked By - Clifford M. (JavaFixing Volunteer)