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