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

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

    • 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
      }
      

          [JENKINS-68216] Need help: Testing DSL scripts fails after plugin updates due to missing plugin

          Due to my desperation I then tried to add ALL plugins (from my normal Jenkins installation) to the "build.gradle" (not just the 5 from above):

          ...
              testPlugins 'org.jenkins-ci.ui:ace-editor:1.1'
              testPlugins 'org.jenkins-ci.plugins:ansicolor:1.0.1'
              testPlugins 'org.jenkins-ci.plugins:antisamy-markup-formatter:2.7'
              testPlugins 'org.jenkins-ci.plugins:apache-httpcomponents-client-4-api:4.5.13-1.0'
              testPlugins 'org.jenkins-ci.plugins:authentication-tokens:1.4'
              testPlugins 'io.jenkins.blueocean:blueocean:1.25.3'
              testPlugins 'org.jenkins-ci.plugins:blueocean-autofavorite:1.2.5'
              testPlugins 'io.jenkins.blueocean:blueocean-bitbucket-pipeline:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-commons:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-config:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-core-js:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-dashboard:1.25.3'
              testPlugins 'org.jenkins-ci.plugins:blueocean-display-url:2.4.1'
              testPlugins 'io.jenkins.blueocean:blueocean-events:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-git-pipeline:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-github-pipeline:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-i18n:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-jwt:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-personalization:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-pipeline-api-impl:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-pipeline-editor:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-pipeline-scm-api:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-rest:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-rest-impl:1.25.3'
              testPlugins 'io.jenkins.blueocean:blueocean-web:1.25.3'
              testPlugins 'io.jenkins.plugins:bootstrap4-api:4.6.0-3'
              testPlugins 'io.jenkins.plugins:bootstrap5-api:5.1.3-6'
              testPlugins 'org.jenkins-ci.plugins:bouncycastle-api:2.25'
              testPlugins 'org.jenkins-ci.plugins:branch-api:2.1044.v2c007e51b_87f'
              testPlugins 'io.jenkins.plugins:caffeine-api:2.9.2-29.v717aac953ff3'
              testPlugins 'io.jenkins.plugins:checks-api:1.7.2'
              testPlugins 'org.jenkins-ci.plugins:cloudbees-bitbucket-branch-source:762.v969cfe087fc0'
              testPlugins 'org.jenkins-ci.plugins:cloudbees-folder:6.714.v79e858ef76a_2'
              testPlugins 'org.jenkins-ci.plugins:cloudbees-jenkins-advisor:3.3.2'
              testPlugins 'org.jenkins-ci.plugins:command-launcher:1.6'
              testPlugins 'io.jenkins:configuration-as-code:1414.v878271fc496f'
              testPlugins 'org.jenkins-ci.plugins:credentials:1087.v16065d268466'
              testPlugins 'org.jenkins-ci.plugins:credentials-binding:1.27.1'
              testPlugins 'org.jenkins-ci.plugins:display-url-api:2.3.6'
              testPlugins 'org.jenkins-ci.plugins:docker-commons:1.19'
              testPlugins 'org.jenkins-ci.plugins:docker-workflow:1.28'
              testPlugins 'org.jenkins-ci.plugins:durable-task:495.v29cd95ec10f2'
              testPlugins 'io.jenkins.plugins:echarts-api:5.3.0-2'
              testPlugins 'org.jenkins-ci.plugins:email-ext:2.87'
              testPlugins 'org.jvnet.hudson.plugins:favorite:2.4.1'
              testPlugins 'io.jenkins.plugins:font-awesome-api:6.0.0-1'
              testPlugins 'org.jenkins-ci.plugins:git:4.11.0'
              testPlugins 'org.jenkins-ci.plugins:git-client:3.11.0'
              testPlugins 'org.jenkins-ci.plugins:git-server:1.10'
              testPlugins 'com.coravy.hudson.plugins.github:github:1.34.3'
              testPlugins 'org.jenkins-ci.plugins:github-api:1.301-378.v9807bd746da5'
              testPlugins 'org.jenkins-ci.plugins:github-branch-source:1598.v91207e9f9b_4a_'
              testPlugins 'org.jenkins-ci.plugins:gitlab-plugin:1.5.29'
              testPlugins 'org.jenkins-ci.ui:handlebars:3.0.8'
              testPlugins 'org.jenkins-ci.plugins:handy-uri-templates-2-api:2.1.8-1.0'
              testPlugins 'org.jenkins-ci.plugins:htmlpublisher:1.29'
              testPlugins 'org.jenkins-ci.plugins:jackson2-api:2.13.2-260.v43d711474c77'
              testPlugins 'io.jenkins.plugins:javax-activation-api:1.2.0-2'
              testPlugins 'io.jenkins.plugins:javax-mail-api:1.6.2-5'
              testPlugins 'io.jenkins.plugins:jaxb:2.3.0.1'
              testPlugins 'org.jenkins-ci.plugins:jdk-tool:1.5'
              testPlugins 'io.jenkins.blueocean:jenkins-design-language:1.25.3'
              testPlugins 'io.jenkins.plugins:jersey2-api:2.35-5'
              testPlugins 'io.jenkins.plugins:jjwt-api:0.11.2-9.c8b45b8bb173'
              testPlugins 'org.jenkins-ci.plugins:job-dsl:1.78.3'
              testPlugins 'io.jenkins.plugins:jquery3-api:3.6.0-2'
              testPlugins 'org.jenkins-ci.plugins:jsch:0.1.55.2'
              testPlugins 'org.jenkins-ci.plugins:junit:1.58'
              testPlugins 'org.jenkins-ci.plugins:ldap:2.8'
              testPlugins 'org.6wind.jenkins:lockable-resources:2.14'
              testPlugins 'org.jenkins-ci.plugins:mailer:408.vd726a_1130320'
              testPlugins 'org.jenkins-ci.plugins:matrix-auth:3.1'
              testPlugins 'org.jenkins-ci.plugins:matrix-project:758.v7a_ea_491852f3'
              testPlugins 'org.jenkins-ci.plugins:metrics:4.1.6.1'
              testPlugins 'org.jenkins-ci.ui:momentjs:1.1.1'
              testPlugins 'org.jvnet.hudson.plugins:monitoring:1.91.0'
              testPlugins 'io.jenkins.plugins:okhttp-api:4.9.3-105.vb96869f8ac3a'
              testPlugins 'org.jenkins-ci.plugins:pipeline-build-step:2.16'
              testPlugins 'org.jenkins-ci.plugins:pipeline-graph-analysis:188.v3a01e7973f2c'
              testPlugins 'org.jenkins-ci.plugins:pipeline-input-step:446.vf27b_0b_83500e'
              testPlugins 'org.jenkins-ci.plugins:pipeline-milestone-step:100.v60a_03cd446e1'
              testPlugins 'org.jenkinsci.plugins:pipeline-model-api:2.2075.vce74e77b_ce40'
              testPlugins 'org.jenkinsci.plugins:pipeline-model-definition:2.2075.vce74e77b_ce40'
              testPlugins 'org.jenkinsci.plugins:pipeline-model-extensions:2.2075.vce74e77b_ce40'
              testPlugins 'org.jenkins-ci.plugins.pipeline-stage-view:pipeline-rest-api:2.23'
              testPlugins 'org.jenkins-ci.plugins:pipeline-stage-step:291.vf0a8a7aeeb50'
              testPlugins 'org.jenkinsci.plugins:pipeline-stage-tags-metadata:2.2075.vce74e77b_ce40'
              testPlugins 'org.jenkins-ci.plugins.pipeline-stage-view:pipeline-stage-view:2.23'
              testPlugins 'org.jenkins-ci.plugins:pipeline-utility-steps:2.12.0'
              testPlugins 'org.jenkins-ci.plugins:plain-credentials:1.8'
              testPlugins 'io.jenkins.plugins:plugin-util-api:2.16.0'
              testPlugins 'io.jenkins.plugins:popper-api:1.16.1-2'
              testPlugins 'io.jenkins.plugins:popper2-api:2.11.4-1'
              testPlugins 'org.jenkins-ci.plugins:pubsub-light:1.16'
              testPlugins 'org.jenkins-ci.plugins:scm-api:595.vd5a_df5eb_0e39'
              testPlugins 'org.jenkins-ci.plugins:script-security:1145.vb_cf6cf6ed960'
              testPlugins 'io.jenkins.plugins:snakeyaml-api:1.29.1'
              testPlugins 'org.jenkins-ci.plugins:sse-gateway:1.25'
              testPlugins 'org.jenkins-ci.plugins:ssh-credentials:1.19'
              testPlugins 'org.jenkins-ci.modules:sshd:3.1.0'
              testPlugins 'org.jenkins-ci.plugins:structs:308.v852b473a2b8c'
              testPlugins 'org.jenkins-ci.plugins:support-core:1148.vedff8cb_56a_da_'
              testPlugins 'org.jenkins-ci.plugins:timestamper:1.17'
              testPlugins 'org.jenkins-ci.plugins:token-macro:285.vff7645a_56ff0'
              testPlugins 'org.jenkins-ci.plugins:trilead-api:1.0.13'
              testPlugins 'org.jenkins-ci.plugins:variant:1.4'
              testPlugins 'org.jenkins-ci.plugins.workflow:workflow-api:1143.v2d42f1e9dea_5'
              testPlugins 'org.jenkins-ci.plugins.workflow:workflow-basic-steps:941.vdfe1b_a_132c64'
              testPlugins 'org.jenkins-ci.plugins.workflow:workflow-cps:2683.vd0a_8f6a_1c263'
              testPlugins 'org.jenkins-ci.plugins.workflow:workflow-cps-global-lib:564.ve62a_4eb_b_e039'
              testPlugins 'org.jenkins-ci.plugins.workflow:workflow-durable-task-step:1128.v8c259d125340'
              testPlugins 'org.jenkins-ci.plugins.workflow:workflow-job:1174.vdcb_d054cf74a_'
              testPlugins 'org.jenkins-ci.plugins.workflow:workflow-multibranch:711.vdfef37cda_816'
              testPlugins 'org.jenkins-ci.plugins.workflow:workflow-scm-step:2.13'
              testPlugins 'org.jenkins-ci.plugins.workflow:workflow-step-api:622.vb_8e7c15b_c95a_'
              testPlugins 'org.jenkins-ci.plugins.workflow:workflow-support:815.vd60466279fc8'
          ...
          

          That are 116.

          This does not help/work either.

          During debugging the test in PluginManager it then has 79 plugins (instead of the 116!?) and the problematic plugins like "workflow-cps" and "workflow-job" are missing too.

          plugins = {CopyOnWriteArrayList@9987}  size = 79
           0 = {PluginWrapper@10005} "Plugin:javax-activation-api"
           1 = {PluginWrapper@10006} "Plugin:javax-mail-api"
           2 = {PluginWrapper@10007} "Plugin:sshd"
           3 = {PluginWrapper@10008} "Plugin:bouncycastle-api"
           4 = {PluginWrapper@10009} "Plugin:trilead-api"
           5 = {PluginWrapper@10010} "Plugin:jdk-tool"
           6 = {PluginWrapper@10011} "Plugin:command-launcher"
           7 = {PluginWrapper@10012} "Plugin:script-security"
           8 = {PluginWrapper@10013} "Plugin:jaxb"
           9 = {PluginWrapper@10014} "Plugin:ace-editor"
           10 = {PluginWrapper@10015} "Plugin:ansicolor"
           11 = {PluginWrapper@10016} "Plugin:antisamy-markup-formatter"
           12 = {PluginWrapper@10017} "Plugin:apache-httpcomponents-client-4-api"
           13 = {PluginWrapper@10018} "Plugin:authentication-tokens"
           14 = {PluginWrapper@10019} "Plugin:blueocean-commons"
           15 = {PluginWrapper@10020} "Plugin:blueocean-config"
           16 = {PluginWrapper@10021} "Plugin:blueocean-core-js"
           17 = {PluginWrapper@10022} "Plugin:blueocean-dashboard"
           18 = {PluginWrapper@10023} "Plugin:blueocean-i18n"
           19 = {PluginWrapper@10024} "Plugin:blueocean-jwt"
           20 = {PluginWrapper@10025} "Plugin:blueocean-personalization"
           21 = {PluginWrapper@10026} "Plugin:blueocean-rest"
           22 = {PluginWrapper@10027} "Plugin:blueocean-web"
           23 = {PluginWrapper@10028} "Plugin:bootstrap4-api"
           24 = {PluginWrapper@10029} "Plugin:bootstrap5-api"
           25 = {PluginWrapper@10030} "Plugin:bouncycastle-api"
           26 = {PluginWrapper@10031} "Plugin:branch-api"
           27 = {PluginWrapper@10032} "Plugin:caffeine-api"
           28 = {PluginWrapper@10033} "Plugin:cloudbees-folder"
           29 = {PluginWrapper@10034} "Plugin:cloudbees-jenkins-advisor"
           30 = {PluginWrapper@10035} "Plugin:command-launcher"
           31 = {PluginWrapper@10036} "Plugin:configuration-as-code"
           32 = {PluginWrapper@10037} "Plugin:credentials"
           33 = {PluginWrapper@10038} "Plugin:display-url-api"
           34 = {PluginWrapper@10039} "Plugin:durable-task"
           35 = {PluginWrapper@10040} "Plugin:echarts-api"
           36 = {PluginWrapper@10041} "Plugin:font-awesome-api"
           37 = {PluginWrapper@10042} "Plugin:github-api"
           38 = {PluginWrapper@10043} "Plugin:handlebars"
           39 = {PluginWrapper@10044} "Plugin:handy-uri-templates-2-api"
           40 = {PluginWrapper@10045} "Plugin:jackson2-api"
           41 = {PluginWrapper@10046} "Plugin:javax-activation-api"
           42 = {PluginWrapper@10047} "Plugin:javax-mail-api"
           43 = {PluginWrapper@10048} "Plugin:jaxb"
           44 = {PluginWrapper@10049} "Plugin:jdk-tool"
           45 = {PluginWrapper@10050} "Plugin:jenkins-design-language"
           46 = {PluginWrapper@10051} "Plugin:jersey2-api"
           47 = {PluginWrapper@10052} "Plugin:jjwt-api"
           48 = {PluginWrapper@10053} "Plugin:jquery3-api"
           49 = {PluginWrapper@10054} "Plugin:ldap"
           50 = {PluginWrapper@10055} "Plugin:mailer"
           51 = {PluginWrapper@10056} "Plugin:matrix-auth"
           52 = {PluginWrapper@10057} "Plugin:metrics"
           53 = {PluginWrapper@10058} "Plugin:momentjs"
           54 = {PluginWrapper@10059} "Plugin:monitoring"
           55 = {PluginWrapper@10060} "Plugin:okhttp-api"
           56 = {PluginWrapper@10061} "Plugin:pipeline-milestone-step"
           57 = {PluginWrapper@10062} "Plugin:pipeline-model-api"
           58 = {PluginWrapper@10063} "Plugin:pipeline-stage-step"
           59 = {PluginWrapper@10064} "Plugin:pipeline-stage-tags-metadata"
           60 = {PluginWrapper@10065} "Plugin:plain-credentials"
           61 = {PluginWrapper@10066} "Plugin:plugin-util-api"
           62 = {PluginWrapper@10067} "Plugin:popper-api"
           63 = {PluginWrapper@10068} "Plugin:popper2-api"
           64 = {PluginWrapper@10069} "Plugin:pubsub-light"
           65 = {PluginWrapper@10070} "Plugin:scm-api"
           66 = {PluginWrapper@10071} "Plugin:script-security"
           67 = {PluginWrapper@10072} "Plugin:snakeyaml-api"
           68 = {PluginWrapper@10073} "Plugin:sse-gateway"
           69 = {PluginWrapper@10074} "Plugin:sshd"
           70 = {PluginWrapper@10075} "Plugin:structs"
           71 = {PluginWrapper@10076} "Plugin:support-core"
           72 = {PluginWrapper@10077} "Plugin:timestamper"
           73 = {PluginWrapper@10078} "Plugin:token-macro"
           74 = {PluginWrapper@10079} "Plugin:trilead-api"
           75 = {PluginWrapper@10080} "Plugin:variant"
           76 = {PluginWrapper@10081} "Plugin:workflow-api"
           77 = {PluginWrapper@10082} "Plugin:workflow-scm-step"
           78 = {PluginWrapper@10083} "Plugin:workflow-step-api"
          

          In addition there are additional old versions of I think implicit Jenkins core dependencies (so-called detached plugins according to log?):

          javax-activation-api
          javax-mail-api
          sshd
          bouncycastle-api
          trilead-api
          jdk-tool
          command-launcher
          script-security
          jaxb
          

          Missing plugins:

          blueocean
          blueocean-autofavorite
          blueocean-bitbucket-pipeline
          
          blueocean-display-url
          blueocean-events
          blueocean-git-pipeline
          blueocean-github-pipeline
          
          blueocean-pipeline-api-impl
          blueocean-pipeline-editor
          blueocean-pipeline-scm-api
          
          blueocean-rest-impl
          
          checks-api
          cloudbees-bitbucket-branch-source
          
          credentials-binding
          
          docker-commons
          docker-workflow
          
          email-ext
          favorite
          
          git
          git-client
          git-server
          github
          
          github-branch-source
          gitlab-plugin
          
          htmlpublisher
          
          job-dsl
          
          jsch
          junit
          
          lockable-resources
          
          matrix-project
          
          pipeline-build-step
          pipeline-graph-analysis
          pipeline-input-step
          
          pipeline-model-definition
          pipeline-model-extensions
          pipeline-rest-api
          
          pipeline-stage-view
          pipeline-utility-steps
          
          ssh-credentials
          
          workflow-basic-steps
          workflow-cps
          workflow-cps-global-lib
          workflow-durable-task-step
          workflow-job
          workflow-multibranch
          
          workflow-support
          

          Any help is very much appreciated!

          I am wondering why I should be the only person having this problem?

          Reinhold Füreder added a comment - Due to my desperation I then tried to add ALL plugins (from my normal Jenkins installation) to the "build.gradle" (not just the 5 from above): ... testPlugins 'org.jenkins-ci.ui:ace-editor:1.1' testPlugins 'org.jenkins-ci.plugins:ansicolor:1.0.1' testPlugins 'org.jenkins-ci.plugins:antisamy-markup-formatter:2.7' testPlugins 'org.jenkins-ci.plugins:apache-httpcomponents-client-4-api:4.5.13-1.0' testPlugins 'org.jenkins-ci.plugins:authentication-tokens:1.4' testPlugins 'io.jenkins.blueocean:blueocean:1.25.3' testPlugins 'org.jenkins-ci.plugins:blueocean-autofavorite:1.2.5' testPlugins 'io.jenkins.blueocean:blueocean-bitbucket-pipeline:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-commons:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-config:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-core-js:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-dashboard:1.25.3' testPlugins 'org.jenkins-ci.plugins:blueocean-display-url:2.4.1' testPlugins 'io.jenkins.blueocean:blueocean-events:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-git-pipeline:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-github-pipeline:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-i18n:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-jwt:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-personalization:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-pipeline-api-impl:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-pipeline-editor:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-pipeline-scm-api:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-rest:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-rest-impl:1.25.3' testPlugins 'io.jenkins.blueocean:blueocean-web:1.25.3' testPlugins 'io.jenkins.plugins:bootstrap4-api:4.6.0-3' testPlugins 'io.jenkins.plugins:bootstrap5-api:5.1.3-6' testPlugins 'org.jenkins-ci.plugins:bouncycastle-api:2.25' testPlugins 'org.jenkins-ci.plugins:branch-api:2.1044.v2c007e51b_87f' testPlugins 'io.jenkins.plugins:caffeine-api:2.9.2-29.v717aac953ff3' testPlugins 'io.jenkins.plugins:checks-api:1.7.2' testPlugins 'org.jenkins-ci.plugins:cloudbees-bitbucket-branch-source:762.v969cfe087fc0' testPlugins 'org.jenkins-ci.plugins:cloudbees-folder:6.714.v79e858ef76a_2' testPlugins 'org.jenkins-ci.plugins:cloudbees-jenkins-advisor:3.3.2' testPlugins 'org.jenkins-ci.plugins:command-launcher:1.6' testPlugins 'io.jenkins:configuration-as-code:1414.v878271fc496f' testPlugins 'org.jenkins-ci.plugins:credentials:1087.v16065d268466' testPlugins 'org.jenkins-ci.plugins:credentials-binding:1.27.1' testPlugins 'org.jenkins-ci.plugins:display-url-api:2.3.6' testPlugins 'org.jenkins-ci.plugins:docker-commons:1.19' testPlugins 'org.jenkins-ci.plugins:docker-workflow:1.28' testPlugins 'org.jenkins-ci.plugins:durable-task:495.v29cd95ec10f2' testPlugins 'io.jenkins.plugins:echarts-api:5.3.0-2' testPlugins 'org.jenkins-ci.plugins:email-ext:2.87' testPlugins 'org.jvnet.hudson.plugins:favorite:2.4.1' testPlugins 'io.jenkins.plugins:font-awesome-api:6.0.0-1' testPlugins 'org.jenkins-ci.plugins:git:4.11.0' testPlugins 'org.jenkins-ci.plugins:git-client:3.11.0' testPlugins 'org.jenkins-ci.plugins:git-server:1.10' testPlugins 'com.coravy.hudson.plugins.github:github:1.34.3' testPlugins 'org.jenkins-ci.plugins:github-api:1.301-378.v9807bd746da5' testPlugins 'org.jenkins-ci.plugins:github-branch-source:1598.v91207e9f9b_4a_' testPlugins 'org.jenkins-ci.plugins:gitlab-plugin:1.5.29' testPlugins 'org.jenkins-ci.ui:handlebars:3.0.8' testPlugins 'org.jenkins-ci.plugins:handy-uri-templates-2-api:2.1.8-1.0' testPlugins 'org.jenkins-ci.plugins:htmlpublisher:1.29' testPlugins 'org.jenkins-ci.plugins:jackson2-api:2.13.2-260.v43d711474c77' testPlugins 'io.jenkins.plugins:javax-activation-api:1.2.0-2' testPlugins 'io.jenkins.plugins:javax-mail-api:1.6.2-5' testPlugins 'io.jenkins.plugins:jaxb:2.3.0.1' testPlugins 'org.jenkins-ci.plugins:jdk-tool:1.5' testPlugins 'io.jenkins.blueocean:jenkins-design-language:1.25.3' testPlugins 'io.jenkins.plugins:jersey2-api:2.35-5' testPlugins 'io.jenkins.plugins:jjwt-api:0.11.2-9.c8b45b8bb173' testPlugins 'org.jenkins-ci.plugins:job-dsl:1.78.3' testPlugins 'io.jenkins.plugins:jquery3-api:3.6.0-2' testPlugins 'org.jenkins-ci.plugins:jsch:0.1.55.2' testPlugins 'org.jenkins-ci.plugins:junit:1.58' testPlugins 'org.jenkins-ci.plugins:ldap:2.8' testPlugins 'org.6wind.jenkins:lockable-resources:2.14' testPlugins 'org.jenkins-ci.plugins:mailer:408.vd726a_1130320' testPlugins 'org.jenkins-ci.plugins:matrix-auth:3.1' testPlugins 'org.jenkins-ci.plugins:matrix-project:758.v7a_ea_491852f3' testPlugins 'org.jenkins-ci.plugins:metrics:4.1.6.1' testPlugins 'org.jenkins-ci.ui:momentjs:1.1.1' testPlugins 'org.jvnet.hudson.plugins:monitoring:1.91.0' testPlugins 'io.jenkins.plugins:okhttp-api:4.9.3-105.vb96869f8ac3a' testPlugins 'org.jenkins-ci.plugins:pipeline-build-step:2.16' testPlugins 'org.jenkins-ci.plugins:pipeline-graph-analysis:188.v3a01e7973f2c' testPlugins 'org.jenkins-ci.plugins:pipeline-input-step:446.vf27b_0b_83500e' testPlugins 'org.jenkins-ci.plugins:pipeline-milestone-step:100.v60a_03cd446e1' testPlugins 'org.jenkinsci.plugins:pipeline-model-api:2.2075.vce74e77b_ce40' testPlugins 'org.jenkinsci.plugins:pipeline-model-definition:2.2075.vce74e77b_ce40' testPlugins 'org.jenkinsci.plugins:pipeline-model-extensions:2.2075.vce74e77b_ce40' testPlugins 'org.jenkins-ci.plugins.pipeline-stage-view:pipeline-rest-api:2.23' testPlugins 'org.jenkins-ci.plugins:pipeline-stage-step:291.vf0a8a7aeeb50' testPlugins 'org.jenkinsci.plugins:pipeline-stage-tags-metadata:2.2075.vce74e77b_ce40' testPlugins 'org.jenkins-ci.plugins.pipeline-stage-view:pipeline-stage-view:2.23' testPlugins 'org.jenkins-ci.plugins:pipeline-utility-steps:2.12.0' testPlugins 'org.jenkins-ci.plugins:plain-credentials:1.8' testPlugins 'io.jenkins.plugins:plugin-util-api:2.16.0' testPlugins 'io.jenkins.plugins:popper-api:1.16.1-2' testPlugins 'io.jenkins.plugins:popper2-api:2.11.4-1' testPlugins 'org.jenkins-ci.plugins:pubsub-light:1.16' testPlugins 'org.jenkins-ci.plugins:scm-api:595.vd5a_df5eb_0e39' testPlugins 'org.jenkins-ci.plugins:script-security:1145.vb_cf6cf6ed960' testPlugins 'io.jenkins.plugins:snakeyaml-api:1.29.1' testPlugins 'org.jenkins-ci.plugins:sse-gateway:1.25' testPlugins 'org.jenkins-ci.plugins:ssh-credentials:1.19' testPlugins 'org.jenkins-ci.modules:sshd:3.1.0' testPlugins 'org.jenkins-ci.plugins:structs:308.v852b473a2b8c' testPlugins 'org.jenkins-ci.plugins:support-core:1148.vedff8cb_56a_da_' testPlugins 'org.jenkins-ci.plugins:timestamper:1.17' testPlugins 'org.jenkins-ci.plugins:token-macro:285.vff7645a_56ff0' testPlugins 'org.jenkins-ci.plugins:trilead-api:1.0.13' testPlugins 'org.jenkins-ci.plugins:variant:1.4' testPlugins 'org.jenkins-ci.plugins.workflow:workflow-api:1143.v2d42f1e9dea_5' testPlugins 'org.jenkins-ci.plugins.workflow:workflow-basic-steps:941.vdfe1b_a_132c64' testPlugins 'org.jenkins-ci.plugins.workflow:workflow-cps:2683.vd0a_8f6a_1c263' testPlugins 'org.jenkins-ci.plugins.workflow:workflow-cps-global-lib:564.ve62a_4eb_b_e039' testPlugins 'org.jenkins-ci.plugins.workflow:workflow-durable-task-step:1128.v8c259d125340' testPlugins 'org.jenkins-ci.plugins.workflow:workflow-job:1174.vdcb_d054cf74a_' testPlugins 'org.jenkins-ci.plugins.workflow:workflow-multibranch:711.vdfef37cda_816' testPlugins 'org.jenkins-ci.plugins.workflow:workflow-scm-step:2.13' testPlugins 'org.jenkins-ci.plugins.workflow:workflow-step-api:622.vb_8e7c15b_c95a_' testPlugins 'org.jenkins-ci.plugins.workflow:workflow-support:815.vd60466279fc8' ... That are 116. This does not help/work either. During debugging the test in PluginManager it then has 79 plugins (instead of the 116!?) and the problematic plugins like "workflow-cps" and "workflow-job" are missing too. plugins = {CopyOnWriteArrayList@9987} size = 79 0 = {PluginWrapper@10005} "Plugin:javax-activation-api" 1 = {PluginWrapper@10006} "Plugin:javax-mail-api" 2 = {PluginWrapper@10007} "Plugin:sshd" 3 = {PluginWrapper@10008} "Plugin:bouncycastle-api" 4 = {PluginWrapper@10009} "Plugin:trilead-api" 5 = {PluginWrapper@10010} "Plugin:jdk-tool" 6 = {PluginWrapper@10011} "Plugin:command-launcher" 7 = {PluginWrapper@10012} "Plugin:script-security" 8 = {PluginWrapper@10013} "Plugin:jaxb" 9 = {PluginWrapper@10014} "Plugin:ace-editor" 10 = {PluginWrapper@10015} "Plugin:ansicolor" 11 = {PluginWrapper@10016} "Plugin:antisamy-markup-formatter" 12 = {PluginWrapper@10017} "Plugin:apache-httpcomponents-client-4-api" 13 = {PluginWrapper@10018} "Plugin:authentication-tokens" 14 = {PluginWrapper@10019} "Plugin:blueocean-commons" 15 = {PluginWrapper@10020} "Plugin:blueocean-config" 16 = {PluginWrapper@10021} "Plugin:blueocean-core-js" 17 = {PluginWrapper@10022} "Plugin:blueocean-dashboard" 18 = {PluginWrapper@10023} "Plugin:blueocean-i18n" 19 = {PluginWrapper@10024} "Plugin:blueocean-jwt" 20 = {PluginWrapper@10025} "Plugin:blueocean-personalization" 21 = {PluginWrapper@10026} "Plugin:blueocean-rest" 22 = {PluginWrapper@10027} "Plugin:blueocean-web" 23 = {PluginWrapper@10028} "Plugin:bootstrap4-api" 24 = {PluginWrapper@10029} "Plugin:bootstrap5-api" 25 = {PluginWrapper@10030} "Plugin:bouncycastle-api" 26 = {PluginWrapper@10031} "Plugin:branch-api" 27 = {PluginWrapper@10032} "Plugin:caffeine-api" 28 = {PluginWrapper@10033} "Plugin:cloudbees-folder" 29 = {PluginWrapper@10034} "Plugin:cloudbees-jenkins-advisor" 30 = {PluginWrapper@10035} "Plugin:command-launcher" 31 = {PluginWrapper@10036} "Plugin:configuration-as-code" 32 = {PluginWrapper@10037} "Plugin:credentials" 33 = {PluginWrapper@10038} "Plugin:display-url-api" 34 = {PluginWrapper@10039} "Plugin:durable-task" 35 = {PluginWrapper@10040} "Plugin:echarts-api" 36 = {PluginWrapper@10041} "Plugin:font-awesome-api" 37 = {PluginWrapper@10042} "Plugin:github-api" 38 = {PluginWrapper@10043} "Plugin:handlebars" 39 = {PluginWrapper@10044} "Plugin:handy-uri-templates-2-api" 40 = {PluginWrapper@10045} "Plugin:jackson2-api" 41 = {PluginWrapper@10046} "Plugin:javax-activation-api" 42 = {PluginWrapper@10047} "Plugin:javax-mail-api" 43 = {PluginWrapper@10048} "Plugin:jaxb" 44 = {PluginWrapper@10049} "Plugin:jdk-tool" 45 = {PluginWrapper@10050} "Plugin:jenkins-design-language" 46 = {PluginWrapper@10051} "Plugin:jersey2-api" 47 = {PluginWrapper@10052} "Plugin:jjwt-api" 48 = {PluginWrapper@10053} "Plugin:jquery3-api" 49 = {PluginWrapper@10054} "Plugin:ldap" 50 = {PluginWrapper@10055} "Plugin:mailer" 51 = {PluginWrapper@10056} "Plugin:matrix-auth" 52 = {PluginWrapper@10057} "Plugin:metrics" 53 = {PluginWrapper@10058} "Plugin:momentjs" 54 = {PluginWrapper@10059} "Plugin:monitoring" 55 = {PluginWrapper@10060} "Plugin:okhttp-api" 56 = {PluginWrapper@10061} "Plugin:pipeline-milestone-step" 57 = {PluginWrapper@10062} "Plugin:pipeline-model-api" 58 = {PluginWrapper@10063} "Plugin:pipeline-stage-step" 59 = {PluginWrapper@10064} "Plugin:pipeline-stage-tags-metadata" 60 = {PluginWrapper@10065} "Plugin:plain-credentials" 61 = {PluginWrapper@10066} "Plugin:plugin-util-api" 62 = {PluginWrapper@10067} "Plugin:popper-api" 63 = {PluginWrapper@10068} "Plugin:popper2-api" 64 = {PluginWrapper@10069} "Plugin:pubsub-light" 65 = {PluginWrapper@10070} "Plugin:scm-api" 66 = {PluginWrapper@10071} "Plugin:script-security" 67 = {PluginWrapper@10072} "Plugin:snakeyaml-api" 68 = {PluginWrapper@10073} "Plugin:sse-gateway" 69 = {PluginWrapper@10074} "Plugin:sshd" 70 = {PluginWrapper@10075} "Plugin:structs" 71 = {PluginWrapper@10076} "Plugin:support-core" 72 = {PluginWrapper@10077} "Plugin:timestamper" 73 = {PluginWrapper@10078} "Plugin:token-macro" 74 = {PluginWrapper@10079} "Plugin:trilead-api" 75 = {PluginWrapper@10080} "Plugin:variant" 76 = {PluginWrapper@10081} "Plugin:workflow-api" 77 = {PluginWrapper@10082} "Plugin:workflow-scm-step" 78 = {PluginWrapper@10083} "Plugin:workflow-step-api" In addition there are additional old versions of I think implicit Jenkins core dependencies (so-called detached plugins according to log?): javax-activation-api javax-mail-api sshd bouncycastle-api trilead-api jdk-tool command-launcher script-security jaxb Missing plugins: blueocean blueocean-autofavorite blueocean-bitbucket-pipeline blueocean-display-url blueocean-events blueocean-git-pipeline blueocean-github-pipeline blueocean-pipeline-api-impl blueocean-pipeline-editor blueocean-pipeline-scm-api blueocean-rest-impl checks-api cloudbees-bitbucket-branch-source credentials-binding docker-commons docker-workflow email-ext favorite git git-client git-server github github-branch-source gitlab-plugin htmlpublisher job-dsl jsch junit lockable-resources matrix-project pipeline-build-step pipeline-graph-analysis pipeline-input-step pipeline-model-definition pipeline-model-extensions pipeline-rest-api pipeline-stage-view pipeline-utility-steps ssh-credentials workflow-basic-steps workflow-cps workflow-cps-global-lib workflow-durable-task-step workflow-job workflow-multibranch workflow-support Any help is very much appreciated! I am wondering why I should be the only person having this problem?

          jamietanna Naive question: might this problem be somehow related to JENKINS-68275?

          Reinhold Füreder added a comment - jamietanna Naive question: might this problem be somehow related to JENKINS-68275 ?

          Hey guys!

          Sorry to be late to the party, I think I stumbled on the same issue and managed to fix it.
          I did the same thing as reinholdfuereder and tried to load all my plugins but there were still issues with trilead being loaded in an old version (older than the one I had defined in my testPlugins declarations).

           

          I spot the warnings about plugins being loaded with a wrong name too so I tried to load them with the right names and it worked! It looks like unless the plugins are loaded with the right names, the dependency resolution fails to load them before the plugins that depend on them.

           

          What I did to fix it was an update to the `build.gradle` file so that the plugin files have the right name and the index points to them, which means removing the version from the name.

          Here's my current build.gradle file:

          import java.nio.file.Paths
          
          apply plugin: 'groovy'
          
          sourceSets {
            jobs {
              groovy {
                srcDirs 'jobs'
              }
            }
          }
          
          repositories {
            mavenCentral()
            maven { url 'https://repo.jenkins-ci.org/public/' }
          }
          
          configurations {
            testPlugins {}
          
            // see JENKINS-45512
            testCompile {
              exclude group: 'xalan'
              exclude group: 'xerces'
            }
          }
          
          dependencies {
            testImplementation 'org.yaml:snakeyaml:1.17'
            testImplementation 'org.spockframework:spock-core:1.3-groovy-2.5'
          
            // Jenkins test harness dependencies
            testImplementation 'org.jenkins-ci.main:jenkins-test-harness:2.33'
            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:structs:1.19@jar'
            testImplementation 'org.jenkins-ci.plugins:script-security:1.54@jar'
          
            // plugins to install in test instance
            testPlugins jenkinsPlugins.split(',')
          }
          
          class JenkinsPlugin {
            public String name
            public String fileName
          
            JenkinsPlugin (final String name, final String extension) {
              this.name = name
              this.fileName = "${name}.${extension}"
            }
          }
          
          final Map<String, JenkinsPlugin> pluginsMapping = new HashMap<>()
          
          task resolveTestPlugins(type: Copy) {
            doFirst {
              configurations.testPlugins
                .resolvedConfiguration
                .resolvedArtifacts
                .findAll { it.extension == 'hpi' || it.extension == 'jpi' }
                .each {
                  pluginsMapping[ it.file.name ] = new JenkinsPlugin(it.name, it.extension)
                }
            }
          
            from configurations.testPlugins
            into new File(sourceSets.test.output.resourcesDir, 'test-dependencies')
            include '*.hpi'
            include '*.jpi'
            rename { filePath ->
              final String fileName = Paths.get(filePath).getFileName()
              return pluginsMapping.get(fileName).fileName
            }
          
            doLast {
              new File(destinationDir, 'index')
                .setText(
                  pluginsMapping
                    .values()
                    .collect { it.name }
                    .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
          }
          
          
          

          The diff compared to the official documentation is:

          1. the jobDslVersion, jenkinsVersion and jenkinsPlugins all come from a separate gradle.properties file
          2. the task resolveTestPlugins first maps the actual plugin files to the plugin metadata: expected name (plugin shortName) and file name (shortName + extension)
          3. it renames the actual plugin files to use the expected names
          4. finally, it creates the index with the expected names

          The gradle.properties file can be generated with the following groovy script from your Jenkins instance's script console:

          static def extractFromManifest (final List<String> manifestLines, final String prefix) {
            final String line = manifestLines
              .find { manifestLine -> manifestLine.startsWith(prefix) }
            return line.replace(prefix, "")
          }
          
          final String jenkinsHome = System.getenv("JENKINS_HOME")
          
          class Plugin {
            public String groupId
            public String shortName
            public String version
          
            @Override
            String toString () {
              return "${groupId}:${shortName}:${version}"
            }
          }
          
          //noinspection GrDeprecatedAPIUsage
          final Map<String, Plugin> mavenCoordinates = new FileNameFinder()
            .getFileNames("${jenkinsHome}/plugins", "**/META-INF/MANIFEST.MF")
            .collect { fileName ->
              final List<String> lines = new File(fileName).readLines()
              final String groupId = extractFromManifest(lines, "Group-Id: ")
              final String shortName = extractFromManifest(lines, "Short-Name: ")
              final String version = extractFromManifest(lines, "Plugin-Version: ")
          
              return new Plugin(
                groupId: groupId,
                shortName: shortName,
                version: version)
            }
            .sort { a, b -> a.shortName <=> b.shortName }
            .findAll { plugin -> !plugin.version.contains("private") } // Filter plugins installed from file
            .collectEntries { plugin -> [(plugin.shortName): plugin] }
          
          println "jobDslVersion=${mavenCoordinates.get("job-dsl").version}"
          println "jenkinsVersion=${jenkins.model.Jenkins.getInstance().getVersion()}"
          print 'jenkinsPlugins='
          println mavenCoordinates
            .values()
            .collect { it.toString() }
            .join(',')
           
          
          

          I would've opened a PR to improve the documentation but it's in a GitHub wiki...

          Anyone can confirm whether this is a good fix and if it is find how to contribute to the documentation ?

          Checking Job DSL declarations is not very useful if the plugins that support the jobs are hard to install on the test Jenkins instance

          Cyprien Quilici added a comment - Hey guys! Sorry to be late to the party, I think I stumbled on the same issue and managed to fix it. I did the same thing as reinholdfuereder and tried to load all my plugins but there were still issues with trilead being loaded in an old version (older than the one I had defined in my testPlugins declarations).   I spot the warnings about plugins being loaded with a wrong name too so I tried to load them with the right names and it worked! It looks like unless the plugins are loaded with the right names, the dependency resolution fails to load them before the plugins that depend on them.   What I did to fix it was an update to the `build.gradle` file so that the plugin files have the right name and the index points to them, which means removing the version from the name. Here's my current build.gradle file: import java.nio.file.Paths apply plugin: 'groovy' sourceSets { jobs { groovy { srcDirs 'jobs' } } } repositories { mavenCentral() maven { url 'https: //repo.jenkins-ci.org/ public /' } } configurations { testPlugins {} // see JENKINS-45512 testCompile { exclude group: 'xalan' exclude group: 'xerces' } } dependencies { testImplementation 'org.yaml:snakeyaml:1.17' testImplementation 'org.spockframework:spock-core:1.3-groovy-2.5' // Jenkins test harness dependencies testImplementation 'org.jenkins-ci.main:jenkins-test-harness:2.33' 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:structs:1.19@jar' testImplementation 'org.jenkins-ci.plugins:script-security:1.54@jar' // plugins to install in test instance testPlugins jenkinsPlugins.split( ',' ) } class JenkinsPlugin { public String name public String fileName JenkinsPlugin ( final String name, final String extension) { this .name = name this .fileName = "${name}.${extension}" } } final Map< String , JenkinsPlugin> pluginsMapping = new HashMap<>() task resolveTestPlugins(type: Copy) { doFirst { configurations.testPlugins .resolvedConfiguration .resolvedArtifacts .findAll { it.extension == 'hpi' || it.extension == 'jpi' } .each { pluginsMapping[ it.file.name ] = new JenkinsPlugin(it.name, it.extension) } } from configurations.testPlugins into new File(sourceSets.test.output.resourcesDir, 'test-dependencies' ) include '*.hpi' include '*.jpi' rename { filePath -> final String fileName = Paths.get(filePath).getFileName() return pluginsMapping.get(fileName).fileName } doLast { new File(destinationDir, 'index' ) .setText( pluginsMapping .values() .collect { it.name } .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 } The diff compared to the official documentation is: the jobDslVersion, jenkinsVersion and jenkinsPlugins all come from a separate gradle.properties file the task resolveTestPlugins first maps the actual plugin files to the plugin metadata: expected name (plugin shortName) and file name (shortName + extension) it renames the actual plugin files to use the expected names finally, it creates the index with the expected names The gradle.properties file can be generated with the following groovy script from your Jenkins instance's script console: static def extractFromManifest ( final List< String > manifestLines, final String prefix) { final String line = manifestLines .find { manifestLine -> manifestLine.startsWith(prefix) } return line.replace(prefix, "") } final String jenkinsHome = System .getenv( "JENKINS_HOME" ) class Plugin { public String groupId public String shortName public String version @Override String toString () { return "${groupId}:${shortName}:${version}" } } //noinspection GrDeprecatedAPIUsage final Map< String , Plugin> mavenCoordinates = new FileNameFinder() .getFileNames( "${jenkinsHome}/plugins" , "**/META-INF/MANIFEST.MF" ) .collect { fileName -> final List< String > lines = new File(fileName).readLines() final String groupId = extractFromManifest(lines, "Group-Id: " ) final String shortName = extractFromManifest(lines, " Short -Name: " ) final String version = extractFromManifest(lines, "Plugin-Version: " ) return new Plugin( groupId: groupId, shortName: shortName, version: version) } .sort { a, b -> a.shortName <=> b.shortName } .findAll { plugin -> !plugin.version.contains( " private " ) } // Filter plugins installed from file .collectEntries { plugin -> [(plugin.shortName): plugin] } println "jobDslVersion=${mavenCoordinates.get(" job-dsl ").version}" println "jenkinsVersion=${jenkins.model.Jenkins.getInstance().getVersion()}" print 'jenkinsPlugins=' println mavenCoordinates .values() .collect { it.toString() } .join( ',' ) I would've opened a PR to improve the documentation but it's in a GitHub wiki... Anyone can confirm whether this is a good fix and if it is find how to contribute to the documentation ? Checking Job DSL declarations is not very useful if the plugins that support the jobs are hard to install on the test Jenkins instance

          jamietanna Any news about this? Is this the right communication channel?

          Cyprien Quilici added a comment - jamietanna Any news about this? Is this the right communication channel?

          (First of all sorry for the huge delay in responding; unfortunately there was a good reason...)

          Thanks quilicicf: your approach really helped me!

          When adding the full list of plugins (via your second code block), and resolving them according to your first it worked right away

          Interestingly I could then also get it running by reducing the list of plugins to install from my initial approach (that used to work right before some of the plugin updates):

          dependencies {
              ...
              // plugins to install in test instance
              testPlugins 'org.jenkins-ci.plugins:cloudbees-folder:6.722.v8165b_a_cf25e9'
              testPlugins 'org.jenkins-ci.plugins:git:4.11.1' // TODO: leads to stderr warning logs "Failed Loading plugin"
              testPlugins 'org.jenkins-ci.plugins:matrix-auth:3.1.2'
              testPlugins 'org.jenkins-ci.plugins.workflow:workflow-cps:2660.vb_c0412dc4e6d' // TODO (https://issues.jenkins.io/browse/JENKINS-68216) should be:
              //testPlugins 'org.jenkins-ci.plugins.workflow:workflow-cps:2692.v76b_089ccd026'
              testPlugins 'org.jenkins-ci.plugins.workflow:workflow-job:1145.v7f2433caa07f' // TODO (https://issues.jenkins.io/browse/JENKINS-68216) should be:
              //testPlugins 'org.jenkins-ci.plugins.workflow:workflow-job:1181.va_25d15548158'
          }
          

          ... to:

          dependencies {
              ...
              // plugins to install in test instance
              testPlugins 'org.jenkins-ci.plugins:cloudbees-folder:6.722.v8165b_a_cf25e9'
              testPlugins 'org.jenkins-ci.plugins:matrix-auth:3.1.2'
              testPlugins 'org.jenkins-ci.plugins.workflow:workflow-job:1181.va_25d15548158'
          }
          

          (I assume the Job DSL plugin version bump since then to 1.87 is irrelevant.)

          Reinhold Füreder added a comment - (First of all sorry for the huge delay in responding; unfortunately there was a good reason...) Thanks quilicicf : your approach really helped me! When adding the full list of plugins (via your second code block), and resolving them according to your first it worked right away Interestingly I could then also get it running by reducing the list of plugins to install from my initial approach (that used to work right before some of the plugin updates): dependencies { ... // plugins to install in test instance testPlugins 'org.jenkins-ci.plugins:cloudbees-folder:6.722.v8165b_a_cf25e9' testPlugins 'org.jenkins-ci.plugins:git:4.11.1' // TODO: leads to stderr warning logs "Failed Loading plugin" testPlugins 'org.jenkins-ci.plugins:matrix-auth:3.1.2' testPlugins 'org.jenkins-ci.plugins.workflow:workflow-cps:2660.vb_c0412dc4e6d' // TODO (https://issues.jenkins.io/browse/JENKINS-68216) should be: //testPlugins 'org.jenkins-ci.plugins.workflow:workflow-cps:2692.v76b_089ccd026' testPlugins 'org.jenkins-ci.plugins.workflow:workflow-job:1145.v7f2433caa07f' // TODO (https://issues.jenkins.io/browse/JENKINS-68216) should be: //testPlugins 'org.jenkins-ci.plugins.workflow:workflow-job:1181.va_25d15548158' } ... to: dependencies { ... // plugins to install in test instance testPlugins 'org.jenkins-ci.plugins:cloudbees-folder:6.722.v8165b_a_cf25e9' testPlugins 'org.jenkins-ci.plugins:matrix-auth:3.1.2' testPlugins 'org.jenkins-ci.plugins.workflow:workflow-job:1181.va_25d15548158' } (I assume the Job DSL plugin version bump since then to 1.87 is irrelevant.)

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

              Created:
              Updated: