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

javaposse.jobdsl.dsl.Job is not a suitable parent class for javaposse.jobdsl.dsl.jobs.WorkflowJob (org.jenkinsci.plugins.workflow.job.WorkflowJob does not extend hudson.model.AbstractProject)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • job-dsl-plugin
    • Jenkins 1.619
      job-dsl-plugin 1.39
      workflow-plugin 1.10

      javaposse.jobdsl.dsl.jobs.WorkflowJob (which matches org.jenkinsci.plugins.workflow.job.WorkflowJob) extends javaposse.jobdsl.dsl.Job (which mainly matches hudson.model.AbstractProject) whereas hudson.model.AbstractProject is not a parent class of org.jenkinsci.plugins.workflow.job.WorkflowJob.
      That results in invalid configuration file being generated when using the javaposse.jobdsl.dsl.Job API combined with javaposse.jobdsl.dsl.DslFactory#workflowJob(java.lang.String, groovy.lang.Closure).
      That means we cannot trust the delegate type to select which customization to apply.

      Closure foo = {
        if (getDelegate() instanceof javaposse.jobdsl.dsl.Job) {
          // label will generate 'assignedNode' / 'canRoam' elements
          label('XXX')
        }
      }
      // below XML is OK, FreeStyleProject has 'assignedNode' / 'canRoam' via AbstractProject
      freeStyleJob('A', foo)
      
      // below resulting XML does not match org.jenkinsci.plugins.workflow.job.WorkflowJob (does not extend AbstractProject)
      workflowJob('B', foo)
      

            jamietanna Jamie Tanna
            fchuong Frédéric Chuong
            Votes:
            0 Vote for this issue
            Watchers:
            16 Start watching this issue

              Created:
              Updated:
              Resolved: