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:

Architecting Resilient application on AWS

 Great whitepaper on improving resiliency of distributed systems: https://docs.aws.amazon.com/whitepapers/latest/availability-and-beyond-imp...