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:

Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile.

Error when installing NPM  Profile not found. Tried ~/.bashrc, ~/.bash_profile, ~/.zshrc, and ~/.profile. Fix: Run command and try a...