Reputation: 1004
Under the Global Tools Configuration, under Maven installations: I have the name as 'maven_3_5_4' and version as 3.5.4 and 'Install Automatically' is checked.
Below is my Jenkinsfile code:
pipeline {
agent any
tools {
maven 'maven_3_5_4'
}
stages {
stage ('Compile Stage') {
steps {
sh 'maven clean compile'
}
}
stage ('Testing Stage') {
steps {
sh 'maven test'
}
}
}
}
While building the pipeline, I am getting the below error:
/var/lib/jenkins/workspace/pipeline_JenkinsDemo@tmp/durable-975c8dc3/script.sh: maven: not found
I am able to build the project using a Maven project in Jenkins. Then, I moved on to get hands-on on how to deal with pipelines. This is my first Jenkins pipeline and the build is failing. I am not sure how the build is successful when building as a maven project and failing when building the pipeline.
Upvotes: 0
Views: 1130
Reputation: 11470
The tool is called maven but the command to use on shell is mvn
.
This is why you get the maven: not found
error. Correct your pipeline sh and it should run.
sh 'mvn clean compile'
Upvotes: 3