Reputation: 79
I have added the gradle plugin to my jenkins and also configured the "Global tools configuration" to install automatically. When i do a simple "which gradle" from my jenkinsfile, it is not recognised and i get an error "@tmp/durable-30a9c792/script.sh: gradle: not found".
Upvotes: 2
Views: 13452
Reputation: 1
pipeline { tools { gradle 'installation-name' } stages { stage('Build') { steps { withGradle { sh 'gradle --version' } } } } }
Upvotes: 0
Reputation: 593
I am currently having this same problem and was able to get this working using the Declarative Pipeline script. Here's what my Jenkinsfile looks like:
pipeline {
agent any
tools {
gradle "GRADLE_LATEST"
}
stages {
stage('Gradle') {
steps {
sh 'gradle --version'
}
}
}
}
I found this method used in this thread
The syntax for the pipeline script is different whether you are using Declarative vs Scripted explained here
Note from the documentation:
A section defining tools to auto-install and put on the PATH. This is ignored if agent none is specified.
Helpful gradle configuration options with Step 3 potentially solving some installation issues.
Upvotes: 4
Reputation: 15205
I don't know why you're unable to see the gradle executable, even though you checked "install automatically" (I'm not familiar with that mechanism). However, I would recommend you use the "Gradle Wrapper" for CI builds (at least), so that you don't need to install Gradle manually, or even have Jenkins manage it. If you use the Gradle Wrapper, the build itself will manage the installation of Gradle (assuming it can work through your proxy).
Upvotes: 1