Как решить проблемы с загрузкой плагинов в тестовом экземпляре Jenkins - PullRequest
1 голос
/ 28 октября 2019

Я хотел бы протестировать мои задания Jenkins, написанные на job-dsl, и в официальном репозитории job-dsl есть пример, который устарел относительно номеров версий. Итак, я хотел бы добиться того же, что и в примере, но с более новыми версиями.

На основе примера и связанных репозитория я создал следующий build.gradlefile

apply plugin: 'groovy'

ext {
    jobDslVersion = '1.76'
    jenkinsVersion = '2.190.1'
}

sourceSets {
    jobs {
        groovy {
            srcDirs 'generators'
        }
    }
}

repositories {
    jcenter()
    mavenLocal()
    maven {
        url 'https://repo.jenkins-ci.org/public/'
    }
}

configurations {
    testPlugins {}

    // see JENKINS-45512
    testCompile {
        exclude group: 'xalan'
        exclude group: 'xerces'
    }
}

dependencies {
    compile "org.codehaus.groovy:groovy-all:2.5.7"
    compile "org.jenkins-ci.plugins:job-dsl-core:${jobDslVersion}"

    testCompile 'org.spockframework:spock-core:1.3-groovy-2.5'

    // Jenkins test harness dependencies
    testCompile 'org.jenkins-ci.main:jenkins-test-harness:2.56'
    testCompile "org.jenkins-ci.main:jenkins-war:${jenkinsVersion}"

    // Job DSL plugin including plugin dependencies

    testCompile "org.jenkins-ci.plugins:job-dsl:${jobDslVersion}"
    testCompile "org.jenkins-ci.plugins:job-dsl:${jobDslVersion}@jar"
    testCompile 'org.jenkins-ci.plugins:structs:1.20@jar'
    testCompile 'org.jenkins-ci.plugins:script-security:1.63@jar'
    testPlugins 'org.jenkins-ci.plugins:trilead-api:1.0.5@hpi'


    // plugins to install in test instance

    testPlugins 'org.jenkins-ci.plugins:credentials:2.3.0'
    testPlugins 'org.jenkins-ci.plugins:credentials-binding:1.12'

    testPlugins 'org.jenkins-ci.plugins:extra-columns:1.21'
    testPlugins 'org.jenkins-ci.plugins:mailer:1.20'
    testPlugins 'org.jenkins-ci.plugins:build-monitor-plugin:1.12+build.201809061734'

    testPlugins 'org.jenkins-ci.plugins:junit:1.28'
    testPlugins 'org.jenkins-ci.plugins:matrix-project:1.14'
    testPlugins 'org.jenkins-ci.plugins:groovy:2.2'
    testPlugins 'org.jenkins-ci.plugins:htmlpublisher:1.14'

    //testPlugins 'org.jenkins-ci.plugins:badge:1.8'
    testPlugins 'org.jvnet.hudson.plugins:groovy-postbuild:2.5'
    testPlugins 'org.jenkins-ci.plugins:ssh-credentials:1.18'

}

task resolveTestPlugins(type: Copy) {
    from configurations.testPlugins
    into new File(sourceSets.test.output.resourcesDir, 'test-dependencies')
    include '*.hpi'
    include '*.jpi'

    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
}

Но тогда я получил следующую ошибку, даже если я определил более новую версию этого плагина Trilead API. Кроме того, если добавить некоторые другие плагины, которые не будут работать, потому что они зависят друг от друга, я подозреваю, что по какой-то причине Jenkins загружает какую-то версию этих плагинов по умолчанию, и это является причиной проблемы. Есть ли способ распечатать загруженные версии плагинов? Или что я должен сделать, чтобы это исправить?

java.io.IOException: SSH Credentials Plugin version 1.18 failed to load.
 - Trilead API Plugin version 1.0.4 is older than required. To fix, install version 1.0.5 or later.
    at hudson.PluginWrapper.resolvePluginDependencies(PluginWrapper.java:922)
    at hudson.PluginManager$2$1$1.run(PluginManager.java:545)
    at org.jvnet.hudson.reactor.TaskGraphBuilder$TaskImpl.run(TaskGraphBuilder.java:169)
    at org.jvnet.hudson.reactor.Reactor.runTask(Reactor.java:296)
    at jenkins.model.Jenkins$5.runTask(Jenkins.java:1118)
    at org.jvnet.hudson.reactor.Reactor$2.run(Reactor.java:214)
    at org.jvnet.hudson.reactor.Reactor$Node.run(Reactor.java:117)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
...