简体   繁体   中英

C:WINDOWSsystem32configsystemprofileAppDataLocalJenkins.jenkinstoolshudson.tasks.Maven_MavenInstallationmaven/bin/mvn: No such file or directory

I'm running Junkins on a windows machine. The Jenkins is not reorganizing my maven path

     stage('MVN cleanpackage') 
     { 
     def mvnHome = tool name: 'maven', type: 'maven'
     def mvnCMD = "${mvnHome}/bin/mvn"
     sh "${mvnCMD} clean package"
     } 

Error: C:WINDOWSsystem32configsystemprofileAppDataLocalJenkins.jenkinstoolshudson.tasks.Maven_MavenInstallationmaven/bin/mvn clean package C:/WINDOWS/system32/config/systemprofile/AppData/Local/Jenkins/.jenkins/workspace/Docker-app@tmp/durable-68371c14/script.sh: line 1: C:WINDOWSsystem32configsystemprofileAppDataLocalJenkins.jenkinstoolshudson.tasks.Maven_MavenInstallationmaven /bin/mvn: No such file or directory

Seems the " \\ " in your mvnHome value is being interpreted as Unix escape " \\ " characters . If running on a Win host, you probably don't want to invoke "sh" , which is a Unix shell.

You probably want to configure to invoke bat , not sh

Thanks, I updated the code as below and now i can able to build without any error

     stage('MVN cleanpackage') { // for display purposes
     def mvnhome = tool name: 'maven-1', type: 'maven'
     bat "${mvnhome}/bin/mvn clean package"
     }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM