I'd like to setup a simple Multibranch Pipeline for my Spring Boot project. I've created such a Multibranch Pipeline in Jenkins, wired in my GitHub repo where I've pushed a very basic Jenkinsfile with a simple step:
pipeline {
agent any
stages {
stage('Build with unit testing') {
steps {
bat 'mvn clean package'
}
}
}
}
However Jenkins doesn't seem to understand the mvn command, because I get the following message in my build:
'mvn' is not recognized as an internal or external command, operable program or batch file.
In went to the Global Tool Configuration where I tried to specify a Maven installation, but regardless of what I do this configuration doesn't seem to persist (I add my Maven, click Apply/Save, go out and come back to this screen again, and the Maven section is empty again, displaying only the "Maven installations..." button. I guess this is the issue. I've read somewhere that this is a Jenkins bug? But could really decode the solution regarding how to solve this in my Jenkinsfile).
Do you guys have any tips how to overcome this problem?
Thanks!