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

post groovy script throws Null Exception

    Details

    • Type: Bug
    • Status: Reopened (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: build-flow-plugin
    • Labels:
      None
    • Environment:
    • Similar Issues:

      Description

      I am using the build flow project for combining the two different project test results.Then i am in need to change the build status of the aggregated test results so i am using groovy postbuild to change my build status.In that script if any one of the test fails gets failed in any of the projects then i am trying to change the build status to unstable.For that i am calculating the fail counts from both results using groovy script.But when i am trying this it throws the NULL pointer Exception.
      The script i used in the groovy postbuild is

      def testResult = manager.build.testResultAction.result
      def fail = testResult.failCount
      if(fail==NULL)

      { manager.buildSuccess() }

      else

      { manager.buildUnstable() }

      It throws the exception as
      ava.lang.NullPointerException: Cannot get property 'result' on null object
      at org.codehaus.groovy.runtime.NullObject.getProperty(NullObject.java:56)
      at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:156)
      at org.codehaus.groovy.runtime.callsite.NullCallSite.getProperty(NullCallSite.java:44)
      at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGetProperty(AbstractCallSite.java:227)
      at Script1.run(Script1.groovy:1)
      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:580)
      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:618)
      at groovy.lang.GroovyShell.evaluate(GroovyShell.java:589)
      at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SecureGroovyScript.evaluate(SecureGroovyScript.java:166)
      at org.jvnet.hudson.plugins.groovypostbuild.GroovyPostbuildRecorder.perform(GroovyPostbuildRecorder.java:362)
      at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
      at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:782)
      at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:723)
      at hudson.model.Build$BuildExecution.post2(Build.java:185)
      at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:668)
      at hudson.model.Run.execute(Run.java:1763)
      at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
      at hudson.model.ResourceController.execute(ResourceController.java:98)
      at hudson.model.Executor.run(Executor.java:410)

        Attachments

          Activity

          Hide
          ikedam ikedam added a comment -

          I can't get what you want at all.
          It threw null pointer exception as you accessed null.
          It is an issue not of plugins, but of your script, isn't it?

          Show
          ikedam ikedam added a comment - I can't get what you want at all. It threw null pointer exception as you accessed null. It is an issue not of plugins, but of your script, isn't it?
          Hide
          gautham Gautham Rathina kumar added a comment -

          i dont think so because i tested some code taken from GITHUB it also throws the same type of exception

          Show
          gautham Gautham Rathina kumar added a comment - i dont think so because i tested some code taken from GITHUB it also throws the same type of exception
          Hide
          ikedam ikedam added a comment -

          It's not a bug of plugins, but the issue of the user script or the configuration.

          Jenkins users group might help you if you don't know how to write groovy codes.

          Show
          ikedam ikedam added a comment - It's not a bug of plugins, but the issue of the user script or the configuration. Jenkins users group might help you if you don't know how to write groovy codes.
          Hide
          gautham Gautham Rathina kumar added a comment -

          can u please check the code that is given below and tell me whether the code is or not

          Show
          gautham Gautham Rathina kumar added a comment - can u please check the code that is given below and tell me whether the code is or not
          Hide
          ikedam ikedam added a comment -

          No.
          Here is not the place to review your configuration.
          And I already checked your code and said it threw NPE as you accessed null, and that's all.
          If you yet can't get what I mean, try following code. It causes the same result with your code and it shows that this is an issue of your code:

          null.result
          
          Show
          ikedam ikedam added a comment - No. Here is not the place to review your configuration. And I already checked your code and said it threw NPE as you accessed null, and that's all. If you yet can't get what I mean, try following code. It causes the same result with your code and it shows that this is an issue of your code: null .result

            People

            • Assignee:
              Unassigned
              Reporter:
              gautham Gautham Rathina kumar
            • Votes:
              1 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: