Details
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/
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?