declarative pipeline - gradle build tool not working

3,638 views
Skip to first unread message

Bill Dennis

unread,
Feb 15, 2017, 9:40:42 PM2/15/17
to Jenkins Users
Hi -

I'm looking to use gradle to run tests in declarative pipeline jobs.

Looking at docs here under tools I should be able to spec a gradle tool in the tools section:

So I created a job like this:

pipeline {
    agent any
    tools
{
        gradle
"GRADLE_LATEST"
   
}
    stages
{
        stage
('Gradle') {
            steps
{
                sh
'gradle --version'
           
}
       
}
   
}
}

But I am getting an error that gradle is not a valid tool type:

org.codehaus.groovy.control.MultipleCompilationErrorsException: startup failed:
WorkflowScript: 4: Invalid tool type "gradle". Valid tool types: [ant, hudson.tasks.Ant$AntInstallation, com.cloudbees.jenkins.plugins.customtools.CustomTool, org.jenkinsci.plugins.docker.commons.tools.DockerTool, git, hudson.plugins.git.GitTool, hudson.plugins.gradle.GradleInstallation, hudson.plugins.groovy.GroovyInstallation, jdk, hudson.model.JDK, jgit, org.jenkinsci.plugins.gitclient.JGitTool, jgitapache, org.jenkinsci.plugins.gitclient.JGitApacheTool, maven, hudson.tasks.Maven$MavenInstallation, hudson.plugins.mercurial.MercurialInstallation] @ line 4, column 9.
           gradle "GRADLE_LATEST"
           ^

1 error

This is on Jenkins Enterprise 2.32.1.1 with version 1.0 of the Pipeline Model plugins installed and with the gradle tool plugin installed and configured.

Has anyone got gradle to work with declarative pipeline?

I think I had it working with scripted pipeline sytax but I prefer this tools section.

Thanks for any help,
Bill

Indra Gunawan (ingunawa)

unread,
Feb 16, 2017, 2:23:53 AM2/16/17
to jenkins...@googlegroups.com

What is “GRADLE_LATEST”?

You need to go Jenkins and install Gradle Plugin then add  Gradle to the tool in Jenkins 2.x:  Go to Manage Jenkins -> Global Tool Configuration -> Gradle Installation;  In Jenkins 1.x: Go to Manage Jenkins -> Configure System -> Gradle

 

For a Gradle version you install you specify a label and then use that label ex. “Gradle-2.14” in the declarative pipeline

 

tools {

    gradle “Gradle-2.14”

    …

 

}

 

On the node/agent, you better make sure the Gradle you install also available in the same installation location you just did above.

 

 

-Indra

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/e5506ea0-e080-47b3-b885-cba24454ea61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Bill Dennis

unread,
Feb 16, 2017, 3:34:34 AM2/16/17
to Jenkins Users
Yes, I did all that gradle configuration. 'GRADLE_LATEST' is the label we used for our gradle installation. We name it that way so every time we update to the latest gradle, we don't need to change all our jobs that we want to be on the latest gradle version. We also use gradle version specific labels for jobs that are sensitive to the version. It shouldn't be a problem here.

Thanks,
Bill

Damien Coraboeuf

unread,
Feb 16, 2017, 5:00:00 AM2/16/17
to Jenkins Users
Question: why can't you use the Gradle wrapper? This allows you to rely only on a JDK. No need to rely on a Gradle installation.

Bill Dennis

unread,
Feb 16, 2017, 6:31:39 AM2/16/17
to Jenkins Users
I could use gradle wrapper, not used it a lot, but looking at docs I think it requires me to commit a small JAR file as part for the generated gradle wrapper files. We have a no binary files in source control policy.

So I prefer to have Jenkins set up all the tooling for me and we pull it from a local Artifactory repo.

The point of the jenkins declarative pipeline is that you commit the pipeline jenkinsFile with all this alongside your source and Jenkins does the tooling side with these tools definitions. Shouldn't even need to set anything up on the Jenkins slave node (apart from a JVM for jenkins to run the slave) or have binaries in source control. For some reason the documented pipeline gradle tool DSL is not working or I have mis-configured something.

Thanks,
Bill

Bill Dennis

unread,
Feb 16, 2017, 12:40:16 PM2/16/17
to Jenkins Users
For future reference I discovered this issue is fixed by gradle plugin v1.26 - this issue: https://issues.jenkins-ci.org/browse/JENKINS-37394

Indra Gunawan (ingunawa)

unread,
Feb 16, 2017, 1:30:54 PM2/16/17
to jenkins...@googlegroups.com

Nice to know.

 

Thank you

 

From: <jenkins...@googlegroups.com> on behalf of Bill Dennis <bill....@gmail.com>


Reply-To: "jenkins...@googlegroups.com" <jenkins...@googlegroups.com>
Date: Thursday, February 16, 2017 at 9:40 AM
To: Jenkins Users <jenkins...@googlegroups.com>

--

You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages