Unable to use instanceOf on workflow/pipeline class

145 views
Skip to first unread message

Rinaldo DiGiorgio

unread,
Feb 17, 2016, 9:08:24 AM2/17/16
to Jenkins Users
Hi,

 I want to extract all the scm actions from the build. I use the following groovy code

build.allActions.each { item ->
actions = item
  println "ACTIONS: ${actions.class}"
        if ( actions instanceof org.jenkinsci.plugins.workflow.steps.scm.MultiSCMRevisionState) {

..

The above produces 

java.lang.IllegalAccessError: tried to access class org.jenkinsci.plugins.workflow.steps.scm.MultiSCMRevisionState from class Script1$_run_closure1

if I replace with hudson.model.ParametersAction I do not get an exception.

Rinaldo

Baptiste Mathus

unread,
Feb 17, 2016, 11:37:23 AM2/17/16
to jenkins...@googlegroups.com

In general, don't use instanceof for classes coming from different classloaders.
You can use string comparisons between classnames (theClass.getName()).

Cheers

--
You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/c3626d49-ecf2-450d-8f97-9ddf19155e11%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Rinaldo DiGiorgio

unread,
Feb 17, 2016, 5:00:01 PM2/17/16
to Jenkins Users
Thank you.
Reply all
Reply to author
Forward
0 new messages