[JIRA] (JENKINS-61602) Passing script parameters with "|" works on Linux but fails Windows

3 views
Skip to first unread message

dirk.heinrichs@recommind.com (JIRA)

unread,
Mar 20, 2020, 11:27:04 AM3/20/20
to jenkinsc...@googlegroups.com
Dirk Heinrichs created an issue
 
Jenkins / Bug JENKINS-61602
Passing script parameters with "|" works on Linux but fails Windows
Issue Type: Bug Bug
Assignee: vjuranek
Components: groovy-plugin
Created: 2020-03-20 15:26
Environment: Windows
Priority: Minor Minor
Reporter: Dirk Heinrichs

When executing a Groovy script build step, where one of the "Script parameters" arguments contains a "|", the Groovy build step fails. Sample Groovy script (for Groovy 3.x; comment out lines 2 and 3 for lower versions):

// Get dependencies
@GrabConfig(systemClassLoader=true)
@Grab('info.picocli:picocli-groovy:4.2.0')

// Import external modules
import groovy.cli.picocli.CliBuilder

// Parse command line options
def cli = new CliBuilder(name: 'theScript.groovy')
cli.h(type: Boolean, longOpt: 'help', usageHelp: true, required: false, 'Show usage information')
cli.r(type: String, longOpt: 'regex', required: true, args: 1, 'Regular expression (required)')
def opts = cli.parse(args)
opts || System.exit(1)
if(opts.h) {
  cli.usage()
  System.exit(0)
}
println('Regex: ' + opts.r)

With "Script parameters" given as "-r foo|bar", this executes the script on Linux and thus prints

Regex: foo|bar

while it fails on Windows with

'bar' is not recognized as an internal or external command, operable program or batch file.

which means the script isn't even executed. I also tried to quote the regex with single or double quotes and escape the "|" with "^" (CMD) or "`" (Powershell) without any luck.

I would expect this to behave exactly the same on Linux and Windows.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.12#713012-sha1:6e07c38)
Atlassian logo

dirk.heinrichs@recommind.com (JIRA)

unread,
Mar 20, 2020, 11:27:04 AM3/20/20
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages