Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-7162

specifying a cli parameter causes unspecified parameters to be blank

      If you have a parameterized job with multiple parameters, all with default values, you can trigger it via an upstream build and all parameters have the default value as expected. This also works when building it via the CLI if you don't specify parameters.

      However as soon as you specify one parameter like "-p PARAM1=foo" then all the other parameters lose their default value and are blank for the build.

      I would expect that specifying one parameter should still allow others to get the default, otherwise in our scripts that invoke CLI builds, we have to put in every parameter and duplicate the default value which is error-prone and is easy to forget when changing one. Confirmed with a fresh and clean 1.370 Hudson.

          [JENKINS-7162] specifying a cli parameter causes unspecified parameters to be blank

          dogfood added a comment -

          Integrated in hudson_main_trunk #200
          [FIXED-JENKINS-7162]
          Hudson ignores Maven pom.xml path when it is specified as absolute path.
          Provided utility methods for checking whether a path is absolute and
          absolutizing a given path (w.r.t. a base).
          Provided a unit test case for this scenario (@Bug 7261).

          km :
          Files :

          • /trunk/hudson/main/core/src/main/java/hudson/util/IOUtils.java
          • /trunk/hudson/main/test/src/test/java/hudson/maven/MavenProjectTest.java
          • /trunk/hudson/main/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java
          • /trunk/hudson/main/test/src/test/resources/hudson/maven/test-pom-7162.xml
          • /trunk/hudson/main/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java

          dogfood added a comment - Integrated in hudson_main_trunk #200 [FIXED-JENKINS-7162] Hudson ignores Maven pom.xml path when it is specified as absolute path. Provided utility methods for checking whether a path is absolute and absolutizing a given path (w.r.t. a base). Provided a unit test case for this scenario (@Bug 7261). km : Files : /trunk/hudson/main/core/src/main/java/hudson/util/IOUtils.java /trunk/hudson/main/test/src/test/java/hudson/maven/MavenProjectTest.java /trunk/hudson/main/maven-plugin/src/main/java/hudson/maven/MavenModuleSetBuild.java /trunk/hudson/main/test/src/test/resources/hudson/maven/test-pom-7162.xml /trunk/hudson/main/maven-plugin/src/main/java/hudson/maven/MavenModuleSet.java

          mcrooney added a comment -

          Hm, I'm pretty sure that comment is completely irrelevant.

          mcrooney added a comment - Hm, I'm pretty sure that comment is completely irrelevant.

          Danny Staple added a comment -

          This also affects the SSH cli access.
          #JENKINS-11691 looks like a duplicate of this.

          Danny Staple added a comment - This also affects the SSH cli access. # JENKINS-11691 looks like a duplicate of this.

          Danny Staple added a comment - - edited

          Oh and the dogfood comment about integrating a patch is most certainly not mcrooney's patch. As mcrooney mentions - it is a completely different patch for #JENKINS-7261.

          Danny Staple added a comment - - edited Oh and the dogfood comment about integrating a patch is most certainly not mcrooney's patch. As mcrooney mentions - it is a completely different patch for # JENKINS-7261 .

          cjo9900 added a comment -

          As parameters are handled in the own page in the UI, which creates the ParametersAction with all of the displayed items including the defaults that are populated there is no problem.

          From the CLI code it is a different case.

          Just had a look at the code in the BuildCommand.java [1], and in this case it just checks that the parameter name passed in is correct, there is no checking of all the parameter definitions that are attached to the project to get the missing entries.

          for (Entry<String, String> e : parameters.entrySet())

          { String name = e.getKey(); ParameterDefinition pd = pdp.getParameterDefinition(name); if (pd==null) throw new AbortException(String.format("\'%s\' is not a valid parameter. Did you mean %s?", name, EditDistance.findNearest(name, pdp.getParameterDefinitionNames()))); values.add(pd.createValue(this,e.getValue())); }

          a = new ParametersAction(values);

          This should add the missing parameters using the default values.

          [1] https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/BuildCommand.java#L100

          cjo9900 added a comment - As parameters are handled in the own page in the UI, which creates the ParametersAction with all of the displayed items including the defaults that are populated there is no problem. From the CLI code it is a different case. Just had a look at the code in the BuildCommand.java [1] , and in this case it just checks that the parameter name passed in is correct, there is no checking of all the parameter definitions that are attached to the project to get the missing entries. for (Entry<String, String> e : parameters.entrySet()) { String name = e.getKey(); ParameterDefinition pd = pdp.getParameterDefinition(name); if (pd==null) throw new AbortException(String.format("\'%s\' is not a valid parameter. Did you mean %s?", name, EditDistance.findNearest(name, pdp.getParameterDefinitionNames()))); values.add(pd.createValue(this,e.getValue())); } a = new ParametersAction(values); This should add the missing parameters using the default values. [1] https://github.com/jenkinsci/jenkins/blob/master/core/src/main/java/hudson/cli/BuildCommand.java#L100

          cjo9900 added a comment -

          Pull request PULL 540 added to fix this.[1]

          Add all the job defined Parameters to the ParameterAction using Defaults
          if not passed via the command line.

          If this breaks backwards compatibility where these are not expected to be passed, we can introduce a new option to use the defaults for parameters which triggers this behaviour.

          @Option(name="-d",usage="Use defaults for parameters not specified, only valid when -p is used")
          public boolean parameterDefaults = false;

          [1] https://github.com/jenkinsci/jenkins/pull/540

          cjo9900 added a comment - Pull request PULL 540 added to fix this. [1] Add all the job defined Parameters to the ParameterAction using Defaults if not passed via the command line. If this breaks backwards compatibility where these are not expected to be passed, we can introduce a new option to use the defaults for parameters which triggers this behaviour. @Option(name="-d",usage="Use defaults for parameters not specified, only valid when -p is used") public boolean parameterDefaults = false; [1] https://github.com/jenkinsci/jenkins/pull/540

          Code changed in jenkins
          User: c3johnso
          Path:
          core/src/main/java/hudson/cli/BuildCommand.java
          test/src/test/groovy/hudson/cli/BuildCommandTest.groovy
          http://jenkins-ci.org/commit/jenkins/7e0d7c0acba504b8bd205cdb228346bbfa09ddfa
          Log:
          [FIXED JENKINS-7162] Add missing parameters as defaults when called from CLI

          Add all the job defined Parameters to the ParameterAction using Defaults
          if not passed via the command line.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: c3johnso Path: core/src/main/java/hudson/cli/BuildCommand.java test/src/test/groovy/hudson/cli/BuildCommandTest.groovy http://jenkins-ci.org/commit/jenkins/7e0d7c0acba504b8bd205cdb228346bbfa09ddfa Log: [FIXED JENKINS-7162] Add missing parameters as defaults when called from CLI Add all the job defined Parameters to the ParameterAction using Defaults if not passed via the command line.

          Code changed in jenkins
          User: vjuranek
          Path:
          core/src/main/java/hudson/cli/BuildCommand.java
          test/src/test/groovy/hudson/cli/BuildCommandTest.groovy
          http://jenkins-ci.org/commit/jenkins/0ddceed69f86e1e32281561873483c4dbc6ee4dd
          Log:
          Merge pull request #540 from cjo9900/JENKINS-7162

          [FIXED JENKINS-7162] Add missing parameters as defaults when called from...

          Compare: https://github.com/jenkinsci/jenkins/compare/c14c7619c615...0ddceed69f86

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: vjuranek Path: core/src/main/java/hudson/cli/BuildCommand.java test/src/test/groovy/hudson/cli/BuildCommandTest.groovy http://jenkins-ci.org/commit/jenkins/0ddceed69f86e1e32281561873483c4dbc6ee4dd Log: Merge pull request #540 from cjo9900/ JENKINS-7162 [FIXED JENKINS-7162] Add missing parameters as defaults when called from... Compare: https://github.com/jenkinsci/jenkins/compare/c14c7619c615...0ddceed69f86

          dogfood added a comment -

          Integrated in jenkins_main_trunk #1856
          [FIXED JENKINS-7162] Add missing parameters as defaults when called from CLI (Revision 7e0d7c0acba504b8bd205cdb228346bbfa09ddfa)

          Result = UNSTABLE
          chris.3.johnson : 7e0d7c0acba504b8bd205cdb228346bbfa09ddfa
          Files :

          • core/src/main/java/hudson/cli/BuildCommand.java
          • test/src/test/groovy/hudson/cli/BuildCommandTest.groovy

          dogfood added a comment - Integrated in jenkins_main_trunk #1856 [FIXED JENKINS-7162] Add missing parameters as defaults when called from CLI (Revision 7e0d7c0acba504b8bd205cdb228346bbfa09ddfa) Result = UNSTABLE chris.3.johnson : 7e0d7c0acba504b8bd205cdb228346bbfa09ddfa Files : core/src/main/java/hudson/cli/BuildCommand.java test/src/test/groovy/hudson/cli/BuildCommandTest.groovy

          Jason Mechler added a comment -

          Would love to see this backported to LTS.

          Jason Mechler added a comment - Would love to see this backported to LTS.

            Unassigned Unassigned
            mcrooney mcrooney
            Votes:
            3 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: