Workflow plugin and Backslashes - script not recognizing path to maven on windows

63 views
Skip to first unread message

ELIASSAL

unread,
Apr 4, 2015, 7:56:32 AM4/4/15
to jenkins...@googlegroups.com
Hi, I am following the basic tutorial https://github.com/jenkinsci/workflow-plugin/blob/master/TUTORIAL.md, the piecs of script
node {
  git url
: 'https://github.com/jglick/simple-maven-project-with-tests.git'
 
def mvnHome = tool 'maven-3.2.5'
  bat
"${mvnHome}\\bin\\mvn   -B verify"
}

is failing at line  bat "${mvnHome}\\bin\\mvn   -B verify" with the following error
'C:\Program' is not recognized as an internal or external command,

I replaced this with
bat "C:\\M3\\bin\\mvn -B verify"

and it worked fine. So what is the solution to use variables that can have Backslashes

Thanks

Richard Bywater

unread,
Apr 4, 2015, 4:36:17 PM4/4/15
to jenkins...@googlegroups.com

The problem isn't really the backslashes as such but the space in the Maven home variable - personally I always avoid using directories with spaces so not sure how to work around the space issue other than not have one :)

Richard


--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/8352a9db-c120-4ffd-a06e-081fac90e421%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

ELIASSAL

unread,
Apr 6, 2015, 5:06:15 AM4/6/15
to jenkins...@googlegroups.com

Well Richard, when I have setup maven; O followed instructions and placed it in C:\Program Files...........But any programming language should be able to handle this

Peter Vohmann

unread,
Apr 6, 2015, 8:22:42 AM4/6/15
to jenkins...@googlegroups.com
Hi,

The language is perfectly capable to deal with spaces and backslashes,
but the bat  statement, or rather cmd.exe behind it, splits the statement at white spaces.
To avoid the splitting, enclose the command in double quotes, inside of the string.

Please try to write the bat statement it like this and let us know:


node {
  git url: 'https://github.com/jglick/simple-maven-project-with-tests.git'
  def mvnHome = tool 'maven-3.2.5'
  bat "\"${mvnHome}\\bin\\mvn\"   -B verify"
}

Best Regards,
Peter

ELIASSAL

unread,
Apr 11, 2015, 2:16:37 PM4/11/15
to jenkins...@googlegroups.com
Thanks Sir, it worked like a charm now. By the way, any idea fi I can find any documentation oe explanation about the "unarchive" step.

I am not able to understand what the switch MAPPING can do as follows
 
 unarchive mapping: ['src.tar': '.', 'target/petclinic.war': 'petclinic.war']

In one tutorial made available by Cyril le Lerc, we have a statement as follows

 sh "cp -rf petclinic.war /opt/apache-tomcat-8-perfs/webapps/ROOT.war"

This copies petclinic.war to adirectory called ROOT.war/target/petclinic.war
it is not copied in webapps as ROOT.war.

I have posted a question since 1 week but nobody is responding

Thanks again


On Saturday, April 4, 2015 at 1:56:32 PM UTC+2, ELIASSAL wrote:
Reply all
Reply to author
Forward
0 new messages