-
Bug
-
Resolution: Fixed
-
Major
-
None
-
stable-1.565.3
-
Powered by SuggestiMate
The Jenkins CLI can pass in parameters to a parameterized build. It uses the "-p" option for this. The arguments are parsed using args4j. The version of args4j that has been incorporated has a bug in the MapOptionHandler code where it will not accept a parameter value that has an equals sign ("=") in it; instead it will take everything up to the equals sign. The problem appears to be fixed in newer args4j code.
[JENKINS-21160] Jenkins CLI cannot handle arguments with equals signs ("=")
seems this issue is fixed
https://github.com/jenkinsci/jenkins/pull/776
I'm having the issue with Jenkins 1.554.3 + args4j:args4j:2.0.23
https://github.com/kohsuke/args4j/issues/87
If it was fixed with args4j:args4j:2.0.23 then something else may be causing the problem.
created a test job ("test-params") with "ARGS" as string parameter
import hudson.cli.BuildCommand; import java.util.Locale; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.PrintStream; def test(parameter) { locale = Locale.ENGLISH; InputStream stdin; ByteArrayOutputStream out = new ByteArrayOutputStream(); ByteArrayOutputStream err = new ByteArrayOutputStream(); command = new BuildCommand(); String[] args = ["test-params", "-p", parameter]; returnCode = command.main( args.toList(), locale, stdin, new PrintStream(out), new PrintStream(err) ); } test("ARGS=a") test("ARGS=a=b")
both run that were created had ARGS=a.
not able to repro from the stable-1.554.3 war with no plugins, but
seeing this issue with stable-1.554.3 with the following plugins:
(tools)-bash-4.1$ jenkins list-plugins antisamy-markup-formatter AntiSamy Markup Formatter Plugin 1.0 (1.2) windows-slaves Windows Slaves Plugin 1.0 matrix-auth Matrix Authorization Strategy Plugin 1.1 (1.2) mailer Mailer Plugin 1.8 (1.11) external-monitor-job External Monitor Job Type Plugin 1.2 ldap LDAP Plugin 1.8 (1.10.2) pam-auth PAM Authentication plugin 1.1 ant Ant Plugin 1.2 javadoc Javadoc Plugin 1.1 (1.2) throttle-concurrents Throttle Concurrent Builds Plug-in 1.8.2 (1.8.3) token-macro Token Macro Plugin 1.10 run-condition Run Condition Plugin 1.0 multiple-scms Multiple SCMs plugin 0.3 ownership Job and Slave ownership plugin 0.4 (0.5.1) publish-over-ssh Publish Over SSH 1.11 maven-plugin Maven Integration plugin 2.0.3 (2.6) patch-parameter patch-parameter 1.1 (1.2) next-build-number Next Build Number Plugin 1.1 conditional-buildstep conditional-buildstep 1.3.3 credentials Credentials Plugin 1.10 (1.16.1) ssh-credentials SSH Credentials Plugin 1.6.1 (1.9) promoted-builds promoted builds plugin 2.17 (2.18) scm-api SCM API Plugin 0.2 git-client GIT client plugin 1.8.0 (1.10.2) git GIT plugin 2.2.1 (2.2.6) build-failure-analyzer Build Failure Analyzer 1.7.0 (1.10.0) buildgraph-view buildgraph-view 1.1.1 build-flow-plugin CloudBees Build Flow plugin 0.12-SNAPSHOT (private-05/12/2014 16:30-damien) (0.15) build-flow-toolbox-plugin Build Flow Toolbox 0.1-SNAPSHOT (private-05/12/2014 15:23-damien) (0.1) ws-cleanup Workspace Cleanup Plugin 0.20 (0.24) ssh-slaves SSH Slaves plugin 1.6 (1.7.1) log-parser Log Parser Plugin 1.0.8 secret Build Secret plugin 1.7 groovy-postbuild Groovy Postbuild 1.8 (2.0) subversion Subversion Plug-in 2.2 (2.4.3) cvs CVS Plug-in 2.11 (2.12) email-ext Email Extension Plugin 2.37.2.2 (2.38.2) view-job-filters View Job Filters 1.26 postbuildscript Post-Build Script Plug-in 0.16 build-name-setter build-name-setter 1.3 testlink TestLink Plugin 3.10 extensible-choice-parameter Extensible Choice Parameter plugin 1.2.2 rebuild Rebuilder 1.21 (1.22) htmlpublisher HTML Publisher plugin 1.3 copyartifact Copy Artifact Plugin 1.30 (1.31) translation Translation Assistance plugin 1.11 greenballs Green Balls 1.14 artifactdeployer Artifact Deployer Plug-in 0.28 (0.32) claim Claim Plugin 2.3 jenkins-reviewbot jenkins-reviewbot 1.4.2 (2.1.2) selected-tests-executor Tests Selector 1.3.3 clone-workspace-scm Clone Workspace SCM Plug-in 0.6 versionnumber Version Number Plug-In 1.4.1 python Python Plugin 1.2 disk-usage disk-usage plugin 0.23 (0.24) envinject Environment Injector Plugin 1.89 (1.90) cloudbees-folder CloudBees Folders Plugin 4.2.1 (4.6.1)
I will try to see which one is causing the issue.
I'd start the search by getting rid of envinject, and maybe Token Macro.
I set up another environment with the same plugins (and same plugin versions); I am not able to repro.
the only thing i can think of is a botched upgrade (1.532.3 => 1.554.3)
Ok, i just upgraded another system (1.532.3 => 1.565.3) and I am able to repro.
I did remove envinject, and disabled token-macro.
Did removing the plugins help, or did it make no difference? Your comment is unclear.
I meant it did not work properly.
here is what I tried in the script console:
import org.kohsuke.args4j.Argument; import org.kohsuke.args4j.CmdLineException; import org.kohsuke.args4j.CmdLineParser; import org.kohsuke.args4j.Option; import org.kohsuke.args4j.spi.BooleanOptionHandler; import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map.Entry; import java.util.Map; import java.util.HashMap; public class SampleMain { @Option(name="-p",usage="Specify the build parameters in the key=value format.") Map<String,String> parameters = new HashMap<String, String>(); Map<String,String> parameters2 = new HashMap<String, String>(); @Option(name="-P",usage="Specify the build parameters in the key=value format.") protected void setParameter(final String property) { int eqIndex = property.indexOf("="); if (eqIndex == -1) { throw new IllegalArgumentException("build parameters must be specified in the form: <key>=<value>"); } parameters2.put(property.substring(0,eqIndex), property.substring(eqIndex+1)); } } def test(String[] args) { println("test with args: " + args) main = new SampleMain() CmdLineParser parser = new CmdLineParser(main); parser.parseArgument(args) for (Entry<String, String> e : main.parameters.entrySet()) { String name = e.getKey(); String value = e.getValue(); println("[parameters] " + name + ' := ' + value); } for (Entry<String, String> e : main.parameters2.entrySet()) { String name = e.getKey(); String value = e.getValue(); println("[parameters2] " + name + ' := ' + value); } } // test('-p', 'key=value', '-P', 'key=value') test('-p', 'key=value=more', '-P', 'key=value=more')
even though it shows
args4j:args4j:2.0.23
in the "about" form.
jenkins about page:
org.jenkins-ci.main:remoting:2.46 args4j:args4j:2.0.23
https://github.com/jenkinsci/remoting/blob/remoting-2.46/pom.xml#L108-L113
<dependency> <groupId>args4j</groupId> <artifactId>args4j</artifactId> <version>2.0.16</version> <scope>provided</scope> </dependency>
remoting not only depends on args4j but also bundles it.
<execution> <id>bundle-arg4j</id> <phase>process-classes</phase> <goals> <goal>unpack-dependencies</goal> </goals> <configuration> <outputDirectory>${project.build.outputDirectory}</outputDirectory> <includeScope>provided</includeScope> <includeArtifactIds>args4j</includeArtifactIds> <includeGroupIds>args4j</includeGroupIds> </configuration> </execution>
Code changed in jenkins
User: Damien Nozay
Path:
core/pom.xml
http://jenkins-ci.org/commit/jenkins/ec2b7fcc8d9542cd7b39d3c7594b3ba6d174f6b0
Log:
JENKINS-21160: update pom.xml to warn about mismatched args4j
in some circumstances, you may use some older args4j (coming from remoting) when the jenkins about page shows a different version.
Code changed in jenkins
User: Oleg Nenashev
Path:
core/pom.xml
http://jenkins-ci.org/commit/jenkins/a22e20d4670560d98d577c26bfd8e45fa72ecb2f
Log:
Merge pull request #1419 from dnozay/patch-1
JENKINS-21160: update pom.xml to warn about mismatched args4j
Compare: https://github.com/jenkinsci/jenkins/compare/8e0b87c0ace4...a22e20d46705
Code changed in jenkins
User: Kohsuke Kawaguchi
Path:
changelog.html
core/pom.xml
pom.xml
http://jenkins-ci.org/commit/jenkins/72e0b9c53a15306e0a7b7117100f4d1b7ec250b8
Log:
[FIXED JENKINS-6167 JENKINS-21251 JENKINS-21160]
Integrated a newer version of remoting & args4j
Integrated in jenkins_main_trunk #4021
[FIXED JENKINS-6167 JENKINS-21251 JENKINS-21160] (Revision 72e0b9c53a15306e0a7b7117100f4d1b7ec250b8)
Result = SUCCESS
kohsuke : 72e0b9c53a15306e0a7b7117100f4d1b7ec250b8
Files :
- changelog.html
- core/pom.xml
- pom.xml
Fixed on March 2015th
https://github.com/jenkinsci/jenkins/commit/72e0b9c53a15306e0a7b7117100f4d1b7ec250b8
Any help for an alternate fix for this, till we get issue to be in resolved status.