1
votes

I am new to jenkins. I am getting the below error when i am trying to trigger scripted pipeline through jenkins.

/Users/Shared/Jenkins/Home/workspace/pipelinedemo@tmp/durable-a4f2db2a/script.sh: line 1: mvn: command not found

Below is the code snippet .

pipeline {
    agent any 
    stages {
        stage('clone repo and clean it ') { 
            steps {
                sh "rm -rf my-app"
                sh "git clone https://github.com/Testing/my-app"
                sh "mvn clean -f my-app"
            }
        }
        stage('Test') { 
            steps {
                 sh "mvn test -f my-app" 
            }
        }
        stage('Deploy') { 
            steps {
                 sh "mvn package -f my-app"
            }
        }
    }
}

Please note that i am able to run mvn command through freestyle project. i am getting this error from scripted line. Please answer this. thanks in advance. Geeth

1
Make sure Maven path is added to $PATH environment variable on the server where your job is running. - ben5556

1 Answers

-1
votes

ssh to your linux server, then 1. Install maven on your linux machine. 2. Add it to your PATH variable. (you should able to run mvn -version command there) 3. Restart your jenkins service.

Then, you should be able to use it in your pipeline script.