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

JEP-200 Global Pipeline Libraries can't filter class

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      I have maintained a Global Pipeline Library code that uses the "hudson. plugins. my. devops. action. ShareIndexAction" custom class to store some index data that can be read from different job builds. How do I solve the JEP-200 problem when the following error occurs?

      class source:

      #!/usr/bin/groovy
      package hudson.plugins.my.devops.action
      import org.apache.commons.lang.StringUtils
      import hudson.model.Actionclass ShareIndexAction implements Serializable,Action {
          String shareUuid;
          Integer shareIndex;    
          
          ShareIndexAction() {
              this.shareUuid = null;
              this.shareIndex = null;
          }   
      
          ShareIndexAction(def _uuid, def _index=null) {
              this.shareUuid = _uuid;
              this.shareIndex = _index;
          }    
      
          /* interface */
          @NonCPS
          public String getIconFileName() {
              return null
          }    
      
          public String getDisplayName() {
              return "#${this.shareIndex} - ${this.shareUuid}"
          }   
      
          @NonCPS
          public String getUrlName() {
              return null
          }
      }
      

      I use this class in vars/mycode.groovy,when upgrade to jenkins 2.121.2 is has JEP-200 issue。

      job log output:

      java.lang.UnsupportedOperationException: Refusing to marshal hudson.plugins.my.devops.action.ShareIndexAction for security reasons; see https://jenkins.io/redirect/class-filter/
      

        Attachments

          Activity

          Hide
          oleg_nenashev Oleg Nenashev added a comment -

          Jenkins legitimately rejects the class, because it is not whitelisted by default.

          The only way to permit it now is to add the class to the whitelist system property. Alternatively, you can package this class as a plugin

           

          Show
          oleg_nenashev Oleg Nenashev added a comment - Jenkins legitimately rejects the class, because it is not whitelisted by default. The only way to permit it now is to add the class to the whitelist system property. Alternatively, you can package this class as a plugin  
          Hide
          galphy gao fei added a comment - - edited

          Hi , Oleg Nenashev:

          I'm a Jenkins user and developer, and thank you very much for your reply to the issue .

          I'll ask you again, if I don't use the ActionIndex class, there's no alternative to getting a value in the [x, y] range that needs to be unique for each job that's executing, and that job can be released after execution is complete.

          Thank you.

          Show
          galphy gao fei added a comment - - edited Hi , Oleg Nenashev : I'm a Jenkins user and developer, and thank you very much for your reply to the issue . I'll ask you again, if I don't use the ActionIndex class, there's no alternative to getting a value in the [x, y] range that needs to be unique for each job that's executing, and that job can be released after execution is complete. Thank you.
          Hide
          oleg_nenashev Oleg Nenashev added a comment -

          What is the question here?

          As I commented above, there are ways to use the class if you really need that

          Show
          oleg_nenashev Oleg Nenashev added a comment - What is the question here? As I commented above, there are ways to use the class if you really need that
          Hide
          galphy gao fei added a comment -

          Package this class as a plugin? 

          I want to use other methods instead of this class to simply get a unique ordinal.

          Like def index = buildid%10, when buildid = 11 and builid = 21 get the same value 1, but I want to get the unique value.

          Class ShareIndexAction is used because inheritance of the action can be save in the JOB information and get through currentBuild. rawBuild. getPreviousBuildInProgress (). getAction (). I will check the value,if used, loop try change a value.

          Because JEP-200, I'm going to delete ShareIndexAction,so need an alternative method. Can you give guidance?

          Show
          galphy gao fei added a comment - Package this class as a plugin?  I want to use other methods instead of this class to simply get a unique ordinal. Like def index = buildid%10, when buildid = 11 and builid = 21 get the same value 1, but I want to get the unique value. Class ShareIndexAction is used because inheritance of the action can be save in the JOB information and get through currentBuild. rawBuild. getPreviousBuildInProgress (). getAction (). I will check the value,if used, loop try change a value. Because JEP-200, I'm going to delete ShareIndexAction,so need an alternative method. Can you give guidance?

            People

            • Assignee:
              Unassigned
              Reporter:
              galphy gao fei
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: