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

empty tags / revisions list when using Folders - NullPointerException - getParentProject()

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • git-parameter-plugin

      The "git tag" list is blank, even on the second on subsequent runs. We found a Null pointer exception in the jenkins.log:

      2014 10:09:40 AM hudson.ExpressionFactory2$JexlExpression evaluate
      WARNING: Caught exception evaluating: it.revisionMap in /job/SF-Dev/job/Deploy-Auction-GitTag/build. Reason: java.lang.reflect.InvocationTargetException
      java.lang.reflect.InvocationTargetException
          at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
          at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
          at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      ((SNIP))
          at java.lang.Thread.run(Thread.java:744)
      Caused by: java.lang.NullPointerException
          at net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition.generateContents(GitParameterDefinition.java:260)
          at net.uaznia.lukanus.hudson.plugins.gitparameter.GitParameterDefinition.getRevisionMap(GitParameterDefinition.java:386)
          ... 167 more
      

      After reviewing the code (as a non developer of course), the problem appears to be in the getParentProject() method:
      https://github.com/jenkinsci/git-parameter-plugin/blob/git-parameter-0.3.2/src/main/java/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinition.java#L184-L213

      context is set to null, then there is some sort of elaborate sequence that should set context to the project during the loop, but apparently that is not happening.

          [JENKINS-23473] empty tags / revisions list when using Folders - NullPointerException - getParentProject()

          Tommy McNeely added a comment - - edited

          Something that is probably worth noting... We use the Cloud Bees Folder plugin, and the job in question is in a folder. I still don't quite understand why its starting at the top level trying to find itself, but I am betting that the folders thing is throwing it off.

          I feel like ParamaterDefinition really needs a .getParent() similar to "Item" ? This can't be the only parameter plugin that would want some other information from its parent project?

          ~tommy

          Tommy McNeely added a comment - - edited Something that is probably worth noting... We use the Cloud Bees Folder plugin, and the job in question is in a folder. I still don't quite understand why its starting at the top level trying to find itself, but I am betting that the folders thing is throwing it off. I feel like ParamaterDefinition really needs a .getParent() similar to "Item" ? This can't be the only parameter plugin that would want some other information from its parent project? ~tommy

          Tommy McNeely added a comment -

          I have confirmed that this bad interaction happens only when using the Cloudbees Folders plugin and while the job is located in a Folder. If the job is moved to the top level, it works fine.

          Tommy McNeely added a comment - I have confirmed that this bad interaction happens only when using the Cloudbees Folders plugin and while the job is located in a Folder. If the job is moved to the top level, it works fine.

          The problem is GitParameterDefinition.java#L186. According to the documentation for Jenkins.getItems, it states that it gets just the immediate children of Jenkins, which would fail with folders.

          Steven Christou added a comment - The problem is GitParameterDefinition.java#L186 . According to the documentation for Jenkins.getItems , it states that it gets just the immediate children of Jenkins, which would fail with folders.

          I created a pull request to fix this issue.

          Steven Christou added a comment - I created a pull request to fix this issue.

          I can also confirm the issue. Moving job from folder to root directory helps.

          Roman Shiryaev added a comment - I can also confirm the issue. Moving job from folder to root directory helps.

          Code changed in jenkins
          User: Nicolas De Loof
          Path:
          src/test/java/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinitionTest.java
          http://jenkins-ci.org/commit/git-parameter-plugin/31bd69caffef594b46833cc69389664b71b71db8
          Log:
          Add unit test for JENKINS-23473.

          based on https://github.com/christ66/git-parameter-plugin/commit/fb8876ce3c6c48c5d03a658bc89851190e6135e5

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Nicolas De Loof Path: src/test/java/net/uaznia/lukanus/hudson/plugins/gitparameter/GitParameterDefinitionTest.java http://jenkins-ci.org/commit/git-parameter-plugin/31bd69caffef594b46833cc69389664b71b71db8 Log: Add unit test for JENKINS-23473 . based on https://github.com/christ66/git-parameter-plugin/commit/fb8876ce3c6c48c5d03a658bc89851190e6135e5

          This issue was fixed by ndeloof in 92971c

          Steven Christou added a comment - This issue was fixed by ndeloof in 92971c

            ndeloof Nicolas De Loof
            tommythekid Tommy McNeely
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: