I want to configure Jenkins 2.375.2 to build gradle project. But when I configure the pipe using Blue Ocean plugin and I run the pipeline I get error:
+ ./gradlew build
/var/lib/jenkins/workspace/jenkins_master@tmp/durable-dcccf1cd/script.sh: 1: ./gradlew: not found
Jenkins file:
pipeline {
agent any
stages {
stage('Build Image') {
steps {
sh "echo 'building..'"
// configure credentials under http://192.168.1.28:8080/user/test/credentials/ and put credentials ID
git credentialsId: '8f6bc3ab-9ef5-4d89-8e14-4972d63325c5 ', url: 'http://192.168.1.30:7990/scm/jen/spring-boot-microservice.git', branch: 'master'
// execute Java -jar ... and build docker image
sh './gradlew build'
sh 'docker build -t springio/gs-spring-boot-docker .'
}
}
}
I tried to add Gradle config
But still I get the same error. Do you know how I can fix this issue?

Here is the documentation from gradle on the latest release 8.1-rc-2. Based on the documentation, I've rewritten your code. Note, that I did not run this code. But I am confident, this would do the trick
In line three, I added
tools{}- to specify the name of the build tool and the path to the build tool. The number '8.1' refers to the name used in the tools config as follows Manage Jenkins > Tools > Gradle > Name > 8.1In line nine,
gradle initmust run before you attempt to generate a wrapper.In line 13,
withGradle{}is optional, refer to the documentation. Also, note that the correct syntax isgradle wrapper buildinstead ofgradlew build