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

File upload option from command line results in NPE.

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • cli
    • None
    • All platforms (reproduced on Macintosh, Windows 7, Unbuntu 10.)

      If the build requires parameters then we can post our request to the following
      url
      http://hudson:8080/hudson/job/WORKSPACE/buildWithParameters?token="XXX"&VARABLE=VALUE
      from the command line.

      How do I pass the source file parameter location into the above URL from the
      command line?.

      Please provide this support in the hudson cli.

          [JENKINS-4296] File upload option from command line results in NPE.

          The syntax is:

          java -jar hudson-cli.jar build NameOfBuild -p parameter_name=path_to_file

          See also http://wiki.jenkins-ci.org/display/JENKINS/Hudson+CLI.

          The ability to specify file parameters via the CLI was implemented in November 2009 (r23543), but has a bug. Here is an example of the build console output:

          Started by command line
          Copying file to null
          FATAL: null
          java.lang.NullPointerException
                  at hudson.FilePath.isAbsolute(FilePath.java:221)
                  at hudson.FilePath.<init>(FilePath.java:209)
                  at hudson.FilePath.child(FilePath.java:891)
                  at hudson.model.FileParameterValue$1.setUp(FileParameterValue.java:85)
                  at hudson.model.Build$RunnerImpl.doRun(Build.java:132)
                  at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:416)
                  at hudson.model.Run.run(Run.java:1241)
                  at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
                  at hudson.model.ResourceController.execute(ResourceController.java:88)
                  at hudson.model.Executor.run(Executor.java:124)
          

          The null value here is the location that the file is copied to within the workspace. After applying the following patch to FileParameterDefinition, the builds are successful and the file is copied into the workspace as expected.

          Index: FileParameterDefinition.java
          ===================================================================
          --- FileParameterDefinition.java	(revision 31540)
          +++ FileParameterDefinition.java	(working copy)
          @@ -79,6 +79,8 @@
                   File local = File.createTempFile("hudson","parameter");
                   src.copyTo(new FilePath(local));
           
          -        return new FileParameterValue(getName(), local, getDescription());
          +        FileParameterValue p = new FileParameterValue(getName(), local, getDescription());
          +        p.setLocation(getName());
          +        return p;
               }
           }
          

          Steven G Brown added a comment - The syntax is: java -jar hudson-cli.jar build NameOfBuild -p parameter_name = path_to_file See also http://wiki.jenkins-ci.org/display/JENKINS/Hudson+CLI . The ability to specify file parameters via the CLI was implemented in November 2009 ( r23543 ), but has a bug. Here is an example of the build console output: Started by command line Copying file to null FATAL: null java.lang.NullPointerException at hudson.FilePath.isAbsolute(FilePath.java:221) at hudson.FilePath.<init>(FilePath.java:209) at hudson.FilePath.child(FilePath.java:891) at hudson.model.FileParameterValue$1.setUp(FileParameterValue.java:85) at hudson.model.Build$RunnerImpl.doRun(Build.java:132) at hudson.model.AbstractBuild$AbstractRunner.run(AbstractBuild.java:416) at hudson.model.Run.run(Run.java:1241) at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46) at hudson.model.ResourceController.execute(ResourceController.java:88) at hudson.model.Executor.run(Executor.java:124) The null value here is the location that the file is copied to within the workspace. After applying the following patch to FileParameterDefinition , the builds are successful and the file is copied into the workspace as expected. Index: FileParameterDefinition.java =================================================================== --- FileParameterDefinition.java (revision 31540) +++ FileParameterDefinition.java (working copy) @@ -79,6 +79,8 @@ File local = File.createTempFile("hudson","parameter"); src.copyTo(new FilePath(local)); - return new FileParameterValue(getName(), local, getDescription()); + FileParameterValue p = new FileParameterValue(getName(), local, getDescription()); + p.setLocation(getName()); + return p; } }

          StevenGBrown added a comment -

          Code changed in hudson
          User: : StevenGBrown
          Path:
          trunk/hudson/main/core/src/main/java/hudson/model/FileParameterDefinition.java
          trunk/www/changelog.html
          http://jenkins-ci.org/commit/31582
          Log:
          [FIXED JENKINS-4296] File parameter builds started with the CLI command no longer throw an NPE.

          StevenGBrown added a comment - Code changed in hudson User: : StevenGBrown Path: trunk/hudson/main/core/src/main/java/hudson/model/FileParameterDefinition.java trunk/www/changelog.html http://jenkins-ci.org/commit/31582 Log: [FIXED JENKINS-4296] File parameter builds started with the CLI command no longer throw an NPE.

            stevengbrown Steven G Brown
            vijayj vijayj
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved: