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

File upload option from command line results in NPE.

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Fixed
    • Component/s: cli
    • Labels:
      None
    • Environment:
      All platforms (reproduced on Macintosh, Windows 7, Unbuntu 10.)
    • Similar Issues:

      Description

      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.

        Attachments

          Activity

          Hide
          stevengbrown 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;
               }
           }
          
          Show
          stevengbrown 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; } }
          Hide
          StevenGBrown 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.

          Show
          StevenGBrown 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.

            People

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

              Dates

              Created:
              Updated:
              Resolved: