Hi list,
I am trying to use gradle.wrapper in Groovie pipeline in Jenkins, what is the way of using gradle.wrapper in Groovie Pipeline in Jenkins?
Thanks in Advance
Roger
In case your project uses Gradle Wrapper you can use the following snippet in your Jenkinsfile:
stage(‘Gradle Build’) {
if (isUnix()) {
sh ‘./gradlew clean build’
} else {
bat ‘gradlew.bat clean build’
}
}
If you checkout to subdirectory sub-dir you might want to use
stage(‘Gradle Build’) {
if (isUnix()) {
dir(‘sub-dir’) {sh ‘./gradlew clean build’}
} else {
dir(‘sub-dir’) {bat ‘gradlew.bat clean build’}
}
}
For future reference here an example with the more modern declarative pipeline:
pipeline {
agent any
stages {
stage(‘somestage’) {
steps {
script {
def version = sh (
script: “./gradlew properties -q | grep “version:” | awk ‘{print $2}’”,
returnStdout: true
).trim()
sh “echo Building project in version: $version”
}
}
}
}
}
see also:
https://stackoverflow.com/questions/24936781/gradle-plugin-project-version-number