timja / jenkins-gh-issues-poc-06-18

0 stars 0 forks source link

[JENKINS-64237] CLI shows provided values as "default" #1297

Open timja opened 3 years ago

timja commented 3 years ago

The Jenkins CLI prints a help text when a command is not used correctly. This help text includes information about the default values of parameters that can be specified.

If the invocation that triggers this help text provides values for parameters, those are shown instead of the actual defaults.

Output below based on core PR 4274 which adds the "reason" parameter (and made me wonder what sort of default value "bar" is!?), but affects other commands:

$ java -jar jenkins-cli.jar -webSocket -auth admin:admin -s http://localhost:8080 quiet-down -reason 'bar' -timeout 42 foo

ERROR: No argument is allowed: foo
java -jar jenkins-cli.jar quiet-down [-block] [-reason VAL] [-timeout N]
Quiet down Jenkins, in preparation for a restart. Don’t start any builds.
 -block      : Block until the system really quiets down and no builds are
       running (default: false)
 -reason VAL : Reason for quiet down that will be visible to users (default:
       bar)
 -timeout N  : If non-zero, only block up to the specified number of
       milliseconds (default: 42)
 

Here's a fun one:

$ java -jar jenkins-cli.jar -webSocket -auth admin:admin -s http://localhost:8080 list-jobs foo bar

ERROR: Too many arguments: bar
java -jar jenkins-cli.jar list-jobs [NAME]
Lists all jobs in a specific view or item group.
 NAME : Name of the view (default: foo) 

Originally reported by danielbeck, imported from: CLI shows provided values as "default"
  • status: Open
  • priority: Minor
  • resolution: Unresolved
  • imported: 2022/01/10
timja commented 3 years ago

oleg_nenashev:

The bug was introduced in the original PR with defaults support: https://github.com/kohsuke/args4j/pull/102/files#diff-ae8264f9f90560e7c61c15563435d12ec2fff8b905db41cf85d328e6a9a6e237R375-R379 . getter#getValue() indeed returns the field value