jenkins-pipeline-shared-libraries-gradle-plugin: JENKINS-48885: JenkinsRule always returns null in getPluginManager().getPlugin() on new core versions

Sadly somehow workflow-aggregator plugin can not be found, even if it is on the plugin dependencies list.

pluginDependencies(Action {
        dependency("org.jenkins-ci.plugins.workflow", "workflow-aggregator", "2.5")
        dependency("org.jenkins-ci.plugins", "job-dsl", "1.69")
        dependency("org.6wind.jenkins", "lockable-resources", "2.2")
        dependency("org.jenkinsci.plugins", "pipeline-model-api", "1.2.5")
        dependency("org.jenkinsci.plugins", "pipeline-model-declarative-agent", "1.1.1")
        dependency("org.jenkinsci.plugins", "pipeline-model-definition", "1.2.5")
        dependency("org.jenkinsci.plugins", "pipeline-model-extensions", "1.2.5")
    })

Spock Test:

 given:
            FreeStyleProject freeStyleProject = rule.createFreeStyleProject('project')
            def scripts = new ExecuteDslScripts()
scripts.scriptText = '''
pipelineJob("testPipeline") {}
""".stripIndent())
freeStyleProject.getBuildersList().add(scripts)

 when:
            QueueTaskFuture<WorkflowRun> futureRun = freeStyleProject.scheduleBuild2(0)
 then:
            // JenkinsRule has different assertion capabilities
            WorkflowRun run = rule.assertBuildStatusSuccess(futureRun)
            rule.assertLogContains('''test'''.stripIndent(), run)

Error:

ERROR: (script, line 2) plugin ‘workflow-aggregator’ needs to be installed

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 1
  • Comments: 28 (10 by maintainers)

Most upvoted comments

I was able to work around this issue using a variant of TestDependenciesTask with javaConvention.sourceSets.test.output.resourcesDir changed to javaConvention.sourceSets.integrationTest.output.resourcesDir and the following code in my build.gradle file:

task resolveIntegrationTestDependencies(type: ResolveIntegrationTestDependenciesTask) {
  configuration = configurations.integrationTestRuntimeClasspath
}

tasks.processIntegrationTestResources.dependsOn resolveIntegrationTestDependencies

With this workaround in place, a build/resources/integrationTest/test-dependencies directory gets created and populated with ${artifactId}.hpi files and an index file that contains each artifactId. This eliminated my issue with recent versions of durable-task and workflow-durable-task-step.

I am hopeful that this issue will eventually be resolved upstream so that I can remove the workaround from my local build.

I was able to work around this issue using a variant of TestDependenciesTask with javaConvention.sourceSets.test.output.resourcesDir changed to javaConvention.sourceSets.integrationTest.output.resourcesDir and the following code in my build.gradle file:

task resolveIntegrationTestDependencies(type: ResolveIntegrationTestDependenciesTask) {
  configuration = configurations.integrationTestRuntimeClasspath
}

tasks.processIntegrationTestResources.dependsOn resolveIntegrationTestDependencies

With this workaround in place, a build/resources/integrationTest/test-dependencies directory gets created and populated with ${artifactId}.hpi files and an index file that contains each artifactId. This eliminated my issue with recent versions of durable-task and workflow-durable-task-step.

I am hopeful that this issue will eventually be resolved upstream so that I can remove the workaround from my local build.

Just thought I’d mention the changes I managed to make to my build.gradle.kts which took care of this without extending TestDependenciesTask directly (and incase anyone wants a quick copy-paste solution to the problem).

plugins {
    ...
    id("org.jenkins-ci.jpi") version "0.38.0" apply false
}

tasks {
    ...
    register<org.jenkinsci.gradle.plugins.jpi.TestDependenciesTask>("resolveIntegrationTestDependencies") {
        into {
            val javaConvention = project.convention.getPlugin<JavaPluginConvention>()
            File("${javaConvention.sourceSets.integrationTest.get().output.resourcesDir}/test-dependencies")
        }
        configuration = configurations.integrationTestRuntimeClasspath.get()
    }
    processIntegrationTestResources {
        dependsOn("resolveIntegrationTestDependencies")
    }
}

not that I condone using Kotlin.