Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

'mvn: not found' error even after installing maven plugin

I have configured jenkins plugin ‘Pipeline Maven Integration Plugin’, and has following in my jenkinsfile:

pipeline {
    agent any

    stages {
        stage('Build') {
            steps {
                script {
                    echo 'Building the project...'
                    sh 'mvn clean install'
                }
            }
        }

        stage('Test') {
            steps {
                script {
                    echo 'Running tests...'
                    sh 'mvn test'
                }
            }
        }

        stage('Deploy') {
            steps {
                script {
                    echo 'Deploy step (for demo purposes)...'
                }
            }
        }
    }
}

But build fails with error:

mvn: not found

Why so?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

It looks like the machine Jenkins runs on doesn’t have Maven installed. Please install it and that has to fix your issue.

Instruction is available on the official Maven website here

Or you can run the next commands

$ wget https://dlcdn.apache.org/maven/maven-3/3.9.9/binaries/apache-maven-3.9.9-bin.tar.gz
$ tar -xvf apache-maven-3.9.9-bin.tar.gz
$ mv apache-maven-3.6.3 /opt/

Set M2_HOME variable

M2_HOME='/opt/apache-maven-3.6.3'
PATH="$M2_HOME/bin:$PATH"
export PATH

And check your maven version

mvn -version
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading