Maven tool is not set in Jenkins pipeline
Scenario
Error when building the Jenkins pipeline (Pipeline project style)
Error snippet:
+ mvn clean package
/var/jenkins_home/workspace/atmosphere pipeline/spring-boot-samples/spring-boot-sample-atmosphere@tmp/durable-7c163949/script.sh: 1: /var/jenkins_home/workspace/atmosphere pipeline/spring-boot-samples/spring-boot-sample-atmosphere@tmp/durable-7c163949/script.sh: mvn: not found
Solution
Use the below script to refer to Maven
node
{
def mvn_version = ''
withEnv( ["PATH+MAVEN=${tool mvn_version}/bin"] )
{
sh 'mvn clean package'
}
}
Image of Jenkins Home ->Manage Jenkins ->Global Tool Configuration
Scenario
Error when building the Jenkins pipeline (Pipeline project style)
Error snippet:
+ mvn clean package
/var/jenkins_home/workspace/atmosphere pipeline/spring-boot-samples/spring-boot-sample-atmosphere@tmp/durable-7c163949/script.sh: 1: /var/jenkins_home/workspace/atmosphere pipeline/spring-boot-samples/spring-boot-sample-atmosphere@tmp/durable-7c163949/script.sh: mvn: not found
Solution
Use the below script to refer to Maven
node
{
def mvn_version = '
withEnv( ["PATH+MAVEN=${tool mvn_version}/bin"] )
{
sh 'mvn clean package'
}
}
Image of Jenkins Home ->Manage Jenkins ->Global Tool Configuration
FOR FREESTYLE PROJECT ( REFER TO MAVEN ERROR)
No comments:
Post a Comment