Jenkins Seed Job Unable to Resolve Class

Hi Jenkins experts,

I have a pipeline using Jenkins DSL plugin to generate jobs from the seed job.

In one of the job DSL, I had the following lines:

import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
import org.jenkinsci.plugins.workflow.support.steps.build.RunWrapper
import org.jenkinsci.plugins.workflow.support.steps.build.BuildUpstreamCause
import org.jenkinsci.plugins.workflow.cps.replay.ReplayCause

When trying to build the seed job, I got errors:

unable to resolve class org.jenkinsci.plugins.workflow.support.steps.build.BuildUpstreamCause
 @ line 14, column 1.
   import org.jenkinsci.plugins.workflow.support.steps.build.BuildUpstreamCause

// Same for the RunWrapper and ReplayCause

The mystery is when I tried to rebuild a generated job with the above DSL change (loaded as Jenkins shared library), the import works fine. I also notice the seed job has no issues importing the FlowInterruptedException class which also comes from a plugin. Did I miss anything here? Would appreciate any insight on how to fix it.

Hi @current817,

Could the issue you’re facing be due to the fact that the Jenkins Job DSL plugin and the Pipeline plugin have different classpath?
At least, I think that’s the case. :thinking:

As far as I know, the Job DSL plugin may not have access to all classes that are available in a Pipeline script.

Yeah, that’s also my guess. One mystery is I was able to see some other classes imported from the some plugins without issues.

1 Like