I am fairly new to Gradle so I am almost certainly doing something really silly but I have been trying to solve this for several hours now and I am stuck
I have a Jenkins shared library and I am trying to add tests to it but when I run my tests I get an error with the class path
❯ ./gradlew build test
> Task :compileGroovy FAILED
startup failed:
/Users/stephen.ball/Desktop/foo/vars/foo.groovy: 1: unable to resolve class org.jenkinsci.plugins.pipeline.modeldefinition.Utils
@ line 1, column 1.
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
^
1 error
my vars/foo.groovy
is the following (obviously this is an example)
import org.jenkinsci.plugins.pipeline.modeldefinition.Utils
def call(String skip) {
if (skip == 'blah') {
Utils.markStageSkippedForConditional(skip)
}
return 'Yay!'
}
if I just have a basic function which just returns a String without importing the Utils it works as I would expect
My build settings contain
dependencies {
implementation 'org.codehaus.groovy:groovy-all:3.0.22'
testImplementation 'junit:junit:4.13.2'
implementation "org.jenkins-ci.main:jenkins-core:2.462.2"
implementation 'org.jenkinsci.plugins:pipeline-model-definition:2.2214.vb_b_34b_2ea_9b_83'
}
so I would expect it to be available and if I run ./gradlew help dependencies
it shows in testRuntimeClasspath - Runtime classpath of source set 'test'.
I thought maybe it needed to be testImplementation but that didn’t make any difference
I have been searching for solutions but all the posts I have found are over 5 years old so talk about much older formats of the setting files do didn’t really help
I pushed an example to here to make it a bit clearer
Any help would be much appreciated
Thanks