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

Role based stratedy can't be showed in Config as Code - java null ptr exeption

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • 587.v2872c41fa_e51

      I want to try out config as code plugin.
      I went to Manage Jenkins -> Configuration as Code and then I clicked "View configuration"

      This is yaml output:

        authorizationStrategy:
          roleBased:
            roles:
              global: |-
                FAILED TO EXPORT
                org.jenkinsci.plugins.rolestrategy.casc.GrantedRoles#global: java.lang.NullPointerException
                  at java.util.regex.Matcher.getTextLength(Matcher.java:1283)
                  at java.util.regex.Matcher.reset(Matcher.java:309)
                  at java.util.regex.Matcher.<init>(Matcher.java:229)
                  at java.util.regex.Pattern.matcher(Pattern.java:1093)
                  at org.jenkinsci.plugins.rolestrategy.casc.PermissionFinder.findPermissionId(PermissionFinder.java:42)
                  at org.jenkinsci.plugins.rolestrategy.casc.RoleDefinition.getRole(RoleDefinition.java:48)
                  at org.jenkinsci.plugins.rolestrategy.casc.RoleDefinition.<init>(RoleDefinition.java:41)
                Caused: java.lang.reflect.InvocationTargetException
                  at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                  at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
                  at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
                  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
                  at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.describe(DataBoundConfigurator.java:309)
                  at io.jenkins.plugins.casc.Attribute._describe(Attribute.java:329)
                  at io.jenkins.plugins.casc.Attribute.describe(Attribute.java:258)
                  at io.jenkins.plugins.casc.impl.configurators.DataBoundConfigurator.describe(DataBoundConfigurator.java:317)
                  at io.jenkins.plugins.casc.Attribute._describe(Attribute.java:329)
                  at io.jenkins.plugins.casc.Attribute.describe(Attribute.java:265)
                  at io.jenkins.plugins.casc.BaseConfigurator.compare(BaseConfigurator.java:392)
                  at org.jenkinsci.plugins.rolestrategy.casc.RoleBasedAuthorizationStrategyConfigurator.describe(RoleBasedAuthorizationStrategyConfigurator.java:92)
                  at org.jenkinsci.plugins.rolestrategy.casc.RoleBasedAuthorizationStrategyConfigurator.describe(RoleBasedAuthorizationStrategyConfigurator.java:32)
                  at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$convertToNode$de0cd4f8$1(HeteroDescribableConfigurator.java:282)
                  at io.vavr.CheckedFunction0.lambda$unchecked$52349c75$1(CheckedFunction0.java:247)
                  at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.convertToNode(HeteroDescribableConfigurator.java:282)
                  at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.lambda$describe$5(HeteroDescribableConfigurator.java:107)
                  at io.vavr.control.Option.map(Option.java:392)
                  at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.describe(HeteroDescribableConfigurator.java:107)
                  at io.jenkins.plugins.casc.impl.configurators.HeteroDescribableConfigurator.describe(HeteroDescribableConfigurator.java:55)
                  at io.jenkins.plugins.casc.Attribute._describe(Attribute.java:329)
                  at io.jenkins.plugins.casc.Attribute.describe(Attribute.java:265)
                  at io.jenkins.plugins.casc.Configurator.describe(Configurator.java:181)
      

          [JENKINS-62124] Role based stratedy can't be showed in Config as Code - java null ptr exeption

          RAT thx added a comment -

          I am seeing the same issue.  Would be nice if we could get a temporary workaround. oleg_nenashev

          RAT thx added a comment - I am seeing the same issue.  Would be nice if we could get a temporary workaround. oleg_nenashev

          Divi added a comment -

          I had same issue then I realized that I had an empty role (role with nothing checked). when I deleted this empty role I managed to view jcasc configuration for my roles.

          Divi added a comment - I had same issue then I realized that I had an empty role (role with nothing checked). when I deleted this empty role I managed to view jcasc configuration for my roles.

          Bartosz Nowak added a comment -

          It was fixed recently.

          Bartosz Nowak added a comment - It was fixed recently.

          Bartosz Nowak added a comment -

          Thanks mawinter69

          Bartosz Nowak added a comment - Thanks mawinter69

          I still reproduce something very similar both for the agents and items fields.
          Versions
          Jenkins: 2.361.4
          Configuration as Code Plugin: 1569.vb_72405b_80249
          Role-based Authorization Strategy: 569.v7476f8e4fe29

          I've tried defining both Global, Item and Node roles to avoid empty data structures passed to GrantedRoles: no luck so far.

           

          Davide Cavestro added a comment - I still reproduce something very similar both for the agents and items fields. Versions Jenkins: 2.361.4 Configuration as Code Plugin: 1569.vb_72405b_80249 Role-based Authorization Strategy: 569.v7476f8e4fe29 I've tried defining both Global , Item and Node roles to avoid empty data structures passed to GrantedRoles: no luck so far.  

          Ok so the issue is related to (inconsistent?) data: it is reproducible simply defining a role (i.e. an Item Role) WITHOUT ANY permission.

          This is clearly unwanted, but it happened that all permissions were removed, leading to the issue at export time.

          Davide Cavestro added a comment - Ok so the issue is related to (inconsistent?) data: it is reproducible simply defining a role (i.e. an Item Role) WITHOUT ANY permission. This is clearly unwanted, but it happened that all permissions were removed, leading to the issue at export time.

            mawinter69 Markus Winter
            dumam Bartosz Nowak
            Votes:
            3 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: