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

Need help: Testing DSL scripts fails after plugin updates due to missing plugin

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • job-dsl-plugin
    • None

      Based upon https://github.com/jenkinsci/job-dsl-plugin/wiki/Testing-DSL-Scripts

      After updating Jenkins core from 2.319.3 => 2.332.2 I also updated the plugins in the Gradle build (see below for "gradle.build" script) and with the latest versions of matching plugin versions tests started to fail. => Need help!

      The culprit line in the JobDSL scripts is always the one with pipelineJob(...) {

      Expected no exception to be thrown, but got 'javaposse.jobdsl.dsl.DslScriptException'
      	at app//spock.lang.Specification.noExceptionThrown(Specification.java:118)
      	at com.xortex.tkqs.jenkins.jobdsl.JobScriptsSpec.test script #file.name(JobScriptsSpec.groovy:26)
      Caused by: javaposse.jobdsl.dsl.DslScriptException: (script, line 5) version 2.4 or later of plugin 'workflow-job' needs to be installed
      	at app//javaposse.jobdsl.plugin.JenkinsJobManagement.failOrMarkBuildAsUnstable(JenkinsJobManagement.java:422)
      	at app//javaposse.jobdsl.plugin.JenkinsJobManagement.requireMinimumPluginVersion(JenkinsJobManagement.java:330)
      	at script.run(script:5)
      	at app//javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScript(AbstractDslScriptLoader.groovy:138)
      	at app//javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScriptEngine(AbstractDslScriptLoader.groovy:108)
      	at javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScripts_closure1(AbstractDslScriptLoader.groovy:61)
      	at app//groovy.lang.Closure.call(Closure.java:420)
      	at app//groovy.lang.Closure.call(Closure.java:436)
      	at app//javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScripts(AbstractDslScriptLoader.groovy:46)
      	at app//javaposse.jobdsl.dsl.AbstractDslScriptLoader.runScript(AbstractDslScriptLoader.groovy:87)
      	at com.xortex.tkqs.jenkins.jobdsl.JobScriptsSpec.test script #file.name(JobScriptsSpec.groovy:23)
      

      The culprit plugin updates are actually two in the `testPlugins` Gradle configuration:

      • 'org.jenkins-ci.plugins.workflow:workflow-cps'
        • 2660.vb_c0412dc4e6d ... OK
        • 2680.vf642ed4fa_d55 ... NOT OK
      • 'org.jenkins-ci.plugins.workflow:workflow-job'
        • 1145.v7f2433caa07f ... OK
        • 1156.v7539182e7b_d5 ... NOT OK

      When using either one in a newer version it fails.

      And in my naive poor debugging attempts I have seen exactly those two plugins were then not available in the Jenkins PluginManager's list of plugins; this is the list when the test still succeeds due to using old plugin versions:

      plugins = {CopyOnWriteArrayList@8291}  size = 29
       0 = {PluginWrapper@8305} "Plugin:javax-activation-api"
       1 = {PluginWrapper@8306} "Plugin:javax-mail-api"
       2 = {PluginWrapper@8307} "Plugin:sshd"
       3 = {PluginWrapper@8308} "Plugin:bouncycastle-api"
       4 = {PluginWrapper@8309} "Plugin:trilead-api"
       5 = {PluginWrapper@8310} "Plugin:jdk-tool"
       6 = {PluginWrapper@8311} "Plugin:command-launcher"
       7 = {PluginWrapper@8312} "Plugin:script-security"
       8 = {PluginWrapper@8313} "Plugin:jaxb"
       9 = {PluginWrapper@8314} "Plugin:ace-editor"
       10 = {PluginWrapper@8315} "Plugin:apache-httpcomponents-client-4-api"
       11 = {PluginWrapper@8316} "Plugin:caffeine-api"
       12 = {PluginWrapper@8317} "Plugin:cloudbees-folder"
       13 = {PluginWrapper@8318} "Plugin:credentials"
       14 = {PluginWrapper@8319} "Plugin:display-url-api"
       15 = {PluginWrapper@8320} "Plugin:javax-activation-api"
       16 = {PluginWrapper@8321} "Plugin:javax-mail-api"
       17 = {PluginWrapper@8322} "Plugin:mailer"
       18 = {PluginWrapper@8323} "Plugin:matrix-auth"
       19 = {PluginWrapper@8324} "Plugin:plain-credentials"
       20 = {PluginWrapper@8325} "Plugin:scm-api"
       21 = {PluginWrapper@8326} "Plugin:script-security"
       22 = {PluginWrapper@8327} "Plugin:structs"
       23 = {PluginWrapper@8328} "Plugin:trilead-api"
       24 = {PluginWrapper@8329} "Plugin:workflow-api"
       25 = {PluginWrapper@8330} "Plugin:workflow-job"
       26 = {PluginWrapper@8331} "Plugin:workflow-scm-step"
       27 = {PluginWrapper@8332} "Plugin:workflow-step-api"
       28 = {PluginWrapper@8333} "Plugin:workflow-support"
      

      IMHO potentially relevant changes are:

      But due to my lack of understanding I don't know how to fix the failures => Please help me...

      "gradle.build":

      apply plugin: 'groovy'
      
      ext {
          jobDslVersion = '1.78.3'
          jenkinsVersion = '2.332.2'
      }
      
      sourceSets {
          jobs {
              groovy {
                  srcDirs 'jobdsl'
              }
          }
      }
      
      repositories {
          mavenCentral()
          maven {
              url 'https://repo.jenkins-ci.org/public/'
          }
      }
      
      configurations {
          testPlugins {}
      
          // see JENKINS-45512
          testImplementation {
              exclude group: 'xalan'
              exclude group: 'xerces'
          }
      }
      
      dependencies {
          // Groovy version:
          // Actually Jenkins currently uses Groovy 2.4.21 (Mange Jenkins > Script Console: "println GroovySystem.version")
          testImplementation 'org.spockframework:spock-core:1.3-groovy-2.4'
      
          // Jenkins test harness dependencies
          testImplementation 'org.jenkins-ci.main:jenkins-test-harness:1736.vc72c458c5103'
          testImplementation "org.jenkins-ci.main:jenkins-war:${jenkinsVersion}"
      
          // Job DSL plugin including plugin dependencies
          testImplementation "org.jenkins-ci.plugins:job-dsl:${jobDslVersion}"
          testImplementation "org.jenkins-ci.plugins:job-dsl:${jobDslVersion}@jar"
          testImplementation 'org.jenkins-ci.plugins:script-security:1145.vb_cf6cf6ed960@jar'
          testImplementation 'org.jenkins-ci.plugins:structs:308.v852b473a2b8c@jar'
      
          // plugins to install in test instance
          testPlugins 'org.jenkins-ci.plugins:cloudbees-folder:6.714.v79e858ef76a_2'
          testPlugins 'org.jenkins-ci.plugins:git:4.11.0' // TODO: leads to stderr warning logs "Failed Loading plugin"
          testPlugins 'org.jenkins-ci.plugins:matrix-auth:3.1'
          testPlugins 'org.jenkins-ci.plugins.workflow:workflow-cps:2660.vb_c0412dc4e6d' // TODO: should be:
          //testPlugins 'org.jenkins-ci.plugins.workflow:workflow-cps:2683.vd0a_8f6a_1c263'
          testPlugins 'org.jenkins-ci.plugins.workflow:workflow-job:1145.v7f2433caa07f' // TODO: should be:
          //testPlugins 'org.jenkins-ci.plugins.workflow:workflow-job:1174.vdcb_d054cf74a_'
      
      }
      
      task resolveTestPlugins(type: Copy) {
          from configurations.testPlugins
          into new File(sourceSets.test.output.resourcesDir, 'test-dependencies')
          include '*.hpi'
          include '*.jpi'
      
          //TODO: Rename files to fix stderr warning logs:
          //  WARNING	hudson.ClassicPluginStrategy#createPluginWrapper: encountered /tmp/jenkins851669878165500765/plugins/workflow-support-3.4.jpi under a nonstandard name; expected workflow-support.jpi
          // Debug logging:
          //eachFile { println it.file }
          // See maybe https://blog.mrhaki.com/2010/10/gradle-goodness-renaming-files-while.html
      
          doLast {
              def baseNames = source.collect { it.name[0..it.name.lastIndexOf('.')-1] }
              new File(destinationDir, 'index').setText(baseNames.join('\n'), 'UTF-8')
          }
      }
      
      test {
          dependsOn tasks.resolveTestPlugins
          inputs.files sourceSets.jobs.groovy.srcDirs
      
          // set build directory for Jenkins test harness, JENKINS-26331
          systemProperty 'buildDirectory', project.buildDir.absolutePath
      }
      

            jamietanna Jamie Tanna
            reinholdfuereder Reinhold Füreder
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: