Sunday, May 26, 2019

Maven tool is not set in Jenkins pipeline

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






FOR FREESTYLE PROJECT ( REFER TO MAVEN ERROR)






No comments:

Gray Failures: What is it and how to detect one?

If you are reading this article , i guess you are curious to know about gray failures and different methods to detect gray failures.  Hopefu...