Hi,
I’m new to Gradle and the JVM in general - I’m only using it to write Groovy scripts to run on Jenkins. I have a script that I’m trying to put into a Gradle project purely so that I can check that it compiles and passed CodeNarc; I’d like to make this into a CI pipeline in the future, but offline is fine for now.
Using IntelliJ IDEA, I created a Gradle project and got the default dummy code to compile and lint with CodeNarc, the latter using the plugin. However, my actual script requires org.jenkins-ci.main:jenkins-core:2.121.2
and some plugins, e.g. org.jenkins-ci.plugins:timestamper:1.8.10
. I’ve added these to my dependencies
block as compile
statements and I’ve added the Jenkins repo to repositories
but compileGroovy
still fails, even though the dependencies resolve. I’m using Gradle 4.8/4.9 (IDEA/terminal) and I tried Gradle 3.5.1, which gives the same error.
plugins {
id 'groovy'
}
repositories {
mavenCentral()
maven {
name 'jenkins'
url 'https://repo.jenkins-ci.org/releases/'
}
}
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.15'
compile 'org.jenkins-ci.plugins:timestamper:1.8.10'
}
import hudson.plugins.timestamper.TimestamperBuildWrapper
new TimestamperBuildWrapper()
$ ./gradlew -q compileGroovy
startup failed:
/tmp/jenkins-jobs/src/main/groovy/justImport.groovy: 1: unable to resolve class hudson.plugins.timestamper.TimestamperBuildWrapper
@ line 1, column 1.
import hudson.plugins.timestamper.TimestamperBuildWrapper
^
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':compileGroovy'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 1s