Thouraya Louati
Thouraya Louati

Reputation: 13

Pipeline Script Jenkins

Here is my pipeline jenkins

pipeline {
    agent any
    stages{
    stage('clone and clean repo'){
        steps {
               bat "git clone https://github.com/developper-root/my-app"
               bat "mvn clean -f my-app"
              }
   }

I have this error:

   'mvn' is not recognized as an internal command
    or external, an executable program or a batch file.

But, this command works

C:\Users\ASUS>mvn --version
Apache Maven 3.3.3 (7994120775791599e205a5524ec3e0dfe41d4a06; 2015-04-22T12:57:37+01:00)
Maven home: C:\Users\ASUS\Desktop\Esprit\Ressources JEE\Semaine 1\Outils - JEE\Maven\apache-maven- 
3.3.3\bin\..
Java version: 1.8.0_60, vendor: Oracle Corporation
Java home: C:\Program Files\Java\jdk1.8.0_60\jre
Default locale: fr_FR, platform encoding: Cp1252
OS name: "windows 10", version: "10.0", arch: "amd64", family: "dos"

Kind regards.

Upvotes: 0

Views: 106

Answers (2)

Aditya Malviya
Aditya Malviya

Reputation: 2149

Okay two things here. When using -f flag you specify the pom.xml file so your command should be

mvn -f pom.xml clean package

Secondly if you're executing multiple line in bat file use below syntax

 stage ('Build repo') {
        steps {
         bat '''
               cd folder to pom.xml 
               mvn clean package
             '''
         } 
      }

Upvotes: 0

Sriram
Sriram

Reputation: 165

It seems that MVN_HOME environment variable is not properly set. Are you running the script on Jenkins master directly? If so check if you have MVN_HOME set in Windows. If you are running this script on some slave, check if maven is installed on that machine.

Upvotes: 0

Related Questions