jenkinsci / gradle-jpi-plugin

Build Jenkins Plugins with Gradle
79 stars 50 forks source link

Extension Classes of Dependency Plugins are not loading with gradle version 7.4.1 and gradle-jpi-plugin version 0.49.0 #230

Closed sskrishnav closed 1 year ago

sskrishnav commented 1 year ago

Jenkins and plugins versions report

Environment ```text Jenkins: 2.375.3.4 OS: Linux - 5.4.242-155.348.amzn2.x86_64 Java: 11.0.18 - Red Hat, Inc. (OpenJDK 64-Bit Server VM) --- Parameterized-Remote-Trigger:3.1.6.3 PullRequestInfoPlugin:1.0-SNAPSHOT (private-48286f81-vempc) ace-editor:1.1 ansicolor:1.0.2 ant:481.v7b_09e538fcca antisamy-markup-formatter:155.v795fb_8702324 apache-httpcomponents-client-4-api:4.5.13-138.v4e7d9a_7b_a_e61 artifactory:3.18.1 async-http-client:1.7.24.3 audit-trail:333.vb_e1b_b_0f1238c authentication-tokens:1.4 aws-bucket-credentials:1.0.0 aws-credentials:191.vcb_f183ce58b_9 aws-java-sdk:1.12.287-357.vf82d85a_6eefd aws-java-sdk-cloudformation:1.12.287-357.vf82d85a_6eefd aws-java-sdk-codebuild:1.12.287-357.vf82d85a_6eefd aws-java-sdk-ec2:1.12.287-357.vf82d85a_6eefd aws-java-sdk-ecr:1.12.287-357.vf82d85a_6eefd aws-java-sdk-ecs:1.12.287-357.vf82d85a_6eefd aws-java-sdk-efs:1.12.287-357.vf82d85a_6eefd aws-java-sdk-elasticbeanstalk:1.12.287-357.vf82d85a_6eefd aws-java-sdk-iam:1.12.287-357.vf82d85a_6eefd aws-java-sdk-logs:1.12.287-357.vf82d85a_6eefd aws-java-sdk-minimal:1.12.287-357.vf82d85a_6eefd aws-java-sdk-sns:1.12.287-357.vf82d85a_6eefd aws-java-sdk-sqs:1.12.287-357.vf82d85a_6eefd aws-java-sdk-ssm:1.12.287-357.vf82d85a_6eefd badge:1.9.1 basic-branch-build-strategies:71.vc1421f89888e bitbucket:223.vd12f2bca5430 blueocean:1.27.1 blueocean-autofavorite:1.2.5 blueocean-bitbucket-pipeline:1.27.1 blueocean-commons:1.27.1 blueocean-config:1.27.1 blueocean-core-js:1.27.1 blueocean-dashboard:1.27.1 blueocean-display-url:2.4.1 blueocean-events:1.27.1 blueocean-git-pipeline:1.27.1 blueocean-github-pipeline:1.27.1 blueocean-i18n:1.27.1 blueocean-jira:1.27.1 blueocean-jwt:1.27.1 blueocean-personalization:1.27.1 blueocean-pipeline-api-impl:1.27.1 blueocean-pipeline-editor:1.27.1 blueocean-pipeline-scm-api:1.27.1 blueocean-rest:1.27.1 blueocean-rest-impl:1.27.1 blueocean-web:1.27.1 bootstrap4-api:4.6.0-5 bootstrap5-api:5.2.1-3 bouncycastle-api:2.27 branch-api:2.1071.v1a_188a_562481 build-blocker-plugin:1.7.8 build-failure-analyzer:2.4.0 build-pipeline-plugin:1.5.8 build-queue-trends-plugin:1.0.0 build-timeout:1.28 build-token-root:151.va_e52fe3215fc build-token-trigger:1.0.0 build-user-vars-plugin:1.9 caffeine-api:2.9.3-65.v6a_47d0f4d1fe cbj-build-info-collector:0.0.1-SNAPSHOT (private-2023-06-06T14:29:40Z-vagrant) checks-api:1.8.1 child-jobs-view-plugin:2.1.1 cisco-spark-notifier:1.1.1 claim:516.v36293563731d cloudbees-administrative-monitors:1.0.10 cloudbees-analytics:1.46 cloudbees-assurance:2.276.0.28 cloudbees-aws-cli:1.5.20 cloudbees-bitbucket-branch-source:791.vb_eea_a_476405b cloudbees-blueocean-default-theme:0.8 cloudbees-credentials:3.3 cloudbees-disk-usage-simple:178.v1a_4d2f6359a_8 cloudbees-disk-usage-simple-plugin:0.2 cloudbees-folder:6.800.v71307ca_b_986b cloudbees-folders-plus:3.29 cloudbees-github-reporting:1.32 cloudbees-groovy-view:1.14 cloudbees-ha:4.39 cloudbees-jenkins-advisor:326.v1821e6a_85e3f cloudbees-jsync-archiver:5.25 cloudbees-license:9.71 cloudbees-monitoring:2.16 cloudbees-nodes-plus:1.25 cloudbees-platform-common:1.19 cloudbees-platform-data:1.30 cloudbees-plugin-usage:2.17 cloudbees-request-filter:1.7 cloudbees-ssh-slaves:2.19 cloudbees-support:3.31 cloudbees-template:4.59 cloudbees-uc-data-api:4.50 cloudbees-unified-ui:1.24 cloudbees-view-creation-filter:1.9 cloudbees-workflow-template:3.19 cloudbees-workflow-ui:2.10 code-coverage-api:3.5.0 command-launcher:90.v669d7ccb_7c31 commons-lang3-api:3.12.0-36.vd97de6465d5b_ commons-text-api:1.10.0-27.vb_fa_3896786a_7 conditional-buildstep:1.4.2 config-file-provider:3.11.1 copyartifact:681.va_a_298c7f9c01 credentials:1214.v1de940103927 credentials-binding:523.vd859a_4b_122e6 cucumber:0.0.2 cucumber-reports:5.7.5 cucumber-trends-report:1.3 dashboard-view:2.466.vdfefd95a_b_f8d data-tables-api:1.12.1-4 database:148.v4a_ff2ca_608b_7 database-postgresql:1.2 delivery-pipeline-plugin:1.4.2 discard-old-build:1.07 display-url-api:2.3.7 docker-commons:1.21 docker-java-api:3.2.13-68.va_875df25a_b_45 docker-plugin:1.3.0 docker-workflow:563.vd5d2e5c4007f durable-task:504.vb10d1ae5ba2f ec2-fleet:2.5.2 echarts-api:5.4.0-1 email-ext:2.93 envinject:2.901.v0038b_6471582 envinject-api:1.199.v3ce31253ed13 extended-choice-parameter:359.v35dcfdd0c20d extended-read-permission:3.2 extensible-choice-parameter:1.8.0 external-monitor-job:203.v683c09d993b_9 favorite:2.4.1 file-operations:1.11 flexible-publish:0.16.1 font-awesome-api:6.2.1-1 forensics-api:1.17.0 form-element-path:1.12 gatling:1.3.0 generic-webhook-trigger:1.86.2 git:5.0.0 git-client:4.1.0 git-parameter:0.9.18 git-server:99.va_0826a_b_cdfa_d git-userContent:1.4 github:1.36.1 github-api:1.303-400.v35c2d8258028 github-branch-source:1701.v00cc8184df93 github-organization-folder:1.6 google-oauth-plugin:1.0.7 gradle:2.2 groovy:453.vcdb_a_c5c99890 groovy-postbuild:2.5 h2-api:1.4.199 handlebars:3.0.8 handy-uri-templates-2-api:2.1.8-22.v77d5b_75e6953 hidden-parameter:70.va_40299ce5d83 htmlpublisher:1.31 http_request:1.16 icon-shim:3.0.0 ignore-committer-strategy:1.0.4 infradna-backup:3.38.60 instance-identity:142.v04572ca_5b_265 ionicons-api:31.v4757b_6987003 ivy:2.4 jackson2-api:2.14.1-313.v504cdd45c18b jacoco:3.3.2 jakarta-activation-api:2.0.1-2 jakarta-mail-api:2.0.1-2 javadoc:226.v71211feb_e7e9 javax-activation-api:1.2.0-5 javax-mail-api:1.6.2-8 jaxb:2.3.7-1 jdk-tool:63.v62d2fd4b_4793 jenkins-agile-studio-plugin:8.0.2 jenkins-bitbucket-pr-interaction:2.2.4 jenkins-build-marker-plugin:3.0.0-SNAPSHOT (private-2023-09-03T22:34:31Z-vagrant) jenkins-build-subscription:1.0.0-SNAPSHOT (private-2023-08-26T00:29:45Z-sreer) jenkins-customized-cron-job-plugin:0.0.1-SNAPSHOT (private-2022-07-24T13:24:00Z-sreer) jenkins-design-language:1.27.1 jenkins-kafka-event-job-trigger-plugin:1.0.0 jenkins-link-publisher-plugin:1.0.0 jenkins-pega-junit-plugin:2.0.4 jenkins-pipeline-utility-steps-plugin:1.5.3 jenkins-pipeline-warehouse-plugin:11.1.6-SNAPSHOT (private-2023-10-04T12:33:06Z-vutus) jenkins-pr-queue-plugin:1.16.2 jenkins-remote-helper-plugin:1.0.0 jenkins-s3-artifacts-plugin:2.1.2 jenkins-spark-plugin:1.3.0-SNAPSHOT (private-57a878bc-vagrant) jenkins-test-bugs-cache-plugin:2.0.0-SNAPSHOT (private-2023-10-04T12:41:39Z-vutus) jersey2-api:2.38-1 jira:3.9 jjwt-api:0.11.5-77.v646c772fddb_0 jmh-report:0.9.0 job-dsl:1.82 jobConfigHistory:1198.v4d5736c2308c jquery:1.12.4-1 jquery-detached:1.2.1 jquery3-api:3.6.1-2 jsch:0.1.55.61.va_e9ee26616e7 junit:1166.va_436e268e972 kube-agent-management:1.1.57 kubernetes:3842.v7ff395ed0cf3 kubernetes-client-api:6.3.1-206.v76d3b_6b_14db_b kubernetes-credentials:0.10.0 ldap:659.v8ca_b_a_fe79fa_d lockable-resources:1123.v4002ee23c671 logfilesizechecker:1.5 mailer:438.v02c7f0a_12fa_4 mapdb-api:1.0.9-28.vf251ce40855d mask-passwords:173.v6a_077a_291eb_5 matrix-auth:3.1.6 matrix-combinations-parameter:1.3.2 matrix-project:785.v06b_7f47b_c631 maven-plugin:3.20 mercurial:1260.vdfb_723cdcc81 mesos:2.0 metrics:4.2.13-420.vea_2f17932dd6 mina-sshd-api-common:2.9.2-50.va_0e1f42659a_a mina-sshd-api-core:2.9.2-50.va_0e1f42659a_a mina-sshd-api-scp:2.9.2-50.va_0e1f42659a_a mina-sshd-api-sftp:2.9.2-50.va_0e1f42659a_a momentjs:1.1.1 monitoring:1.94.0 naginator:1.18.2 nectar-license:8.41 nectar-rbac:5.79 new-relic:1.0.4 next-build-number:1.8 nexus-iq-jenkins-plugin:2.19.0-01 nexus-jenkins-plugin:3.16.489.v7cf06846a_c96 node-iterator-api:49.v58a_8b_35f8363 oauth-credentials:0.5 okhttp-api:4.9.3-108.v0feda04578cf one-shot-executor:1.2 opentelemetry:2.11.0 operations-center-agent:2.375.1.1 operations-center-analytics-config:2.222.0.1 operations-center-analytics-reporter:2.222.0.1 operations-center-client:2.375.1.1 operations-center-cloud:2.375.1.3 operations-center-context:2.375.1.4 palace-cloud:2.0.11 pam-auth:1.5.1 parameter-separator:1.3 parameterized-trigger:2.45 performance:918.v5511b_a_d40338 pipeline-aws:1.43 pipeline-build-step:2.18 pipeline-classpath:0.1.0 pipeline-github-lib:38.v445716ea_edda_ pipeline-graph-analysis:202.va_d268e64deb_3 pipeline-groovy-lib:629.vb_5627b_ee2104 pipeline-input-step:466.v6d0a_5df34f81 pipeline-maven:1274.v870c8cb_fa_369 pipeline-milestone-step:111.v449306f708b_7 pipeline-model-api:2.2118.v31fd5b_9944b_5 pipeline-model-declarative-agent:1.1.1 pipeline-model-definition:2.2118.v31fd5b_9944b_5 pipeline-model-extensions:2.2118.v31fd5b_9944b_5 pipeline-rest-api:2.30 pipeline-stage-step:305.ve96d0205c1c6 pipeline-stage-tags-metadata:2.2118.v31fd5b_9944b_5 pipeline-stage-view:2.30 pipeline-utility-steps:2.15.0 plain-credentials:143.v1b_df8b_d3b_e48 plugin-util-api:2.20.0 popper-api:1.16.1-3 popper2-api:2.11.6-2 postbuildscript:3.2.0-460.va_fda_0fa_26720 preSCMbuildstep:44.v6ef4fd97f56e prism-api:1.29.0-2 project-build-times:1.2.1 pse-cje-client-license:1.6.3 pubsub-light:1.17 rebuild:1.34 resource-disposer:0.22 ruby-runtime:0.13 run-condition:1.5 s3:0.12.3436.v674b_46258039 saml:4.385.v4dea_91565e9d scm-api:631.v9143df5b_e4a_a script-security:1229.v4880b_b_e905a_6 sidebar-link:2.2.1 snakeyaml-api:1.33-90.v80dcb_3814d35 sonar:2.15 split-tests-plugin:1.8.5 sse-gateway:1.26 ssh:2.6.1 ssh-agent:295.v9ca_a_1c7cc3a_a_ ssh-credentials:305.v8f4381501156 ssh-slaves:2.854.v7fd446b_337c9 ssh2easy:1.4 sshd:3.275.v9e17c10f2571 stashNotifier:1.28 structs:324.va_f5d6774f3a_d subversion:2.17.1 summary_report:1.15 support-core:1244.vceb_57079258a throttle-concurrents:2.11 tiger-tenant:1.0.15 timestamper:1.21 token-macro:321.vd7cc1f2a_52c8 trilead-api:2.84.v72119de229b_7 unique-id:2.2.1 uno-choice:2.6.5 urltrigger:1.02 user-activity-monitoring:1.9 variant:59.vf075fe829ccb versioncolumn:95.v82f3985cd6e1 view-job-filters:2.3 wikitext:3.16 windows-slaves:1.8.1 workflow-aggregator:590.v6a_d052e5a_a_b_5 workflow-api:1208.v0cc7c6e0da_9e workflow-basic-steps:994.vd57e3ca_46d24 workflow-cps:3606.v0b_d8b_e512dcf workflow-cps-checkpoint:2.14 workflow-cps-global-lib:609.vd95673f149b_b workflow-durable-task-step:1223.v7f1a_98a_8863e workflow-job:1268.v6eb_e2ee1a_85a workflow-multibranch:716.vc692a_e52371b_ workflow-remote-loader:1.5 workflow-scm-step:400.v6b_89a_1317c9a_ workflow-step-api:639.v6eca_cd8c04a_a_ workflow-support:839.v35e2736cfd5c ws-cleanup:0.45 xtrigger-api:1.0 ```

What Operating System are you using (both controller, and any agents involved in the problem)?

We are using amazon linux images for all Jenkins nodes. We hosted the Jenkins in AWS.

Reproduction steps

We have custom plugin called "jenkins-test-bugs-cache-plugin" which is working fine with gradle 5.5 and with gradle-jpi-plugin version 0.33.0.

As part of above plugin we have a custom jenkins dependency added as "jenkinsPlugins('com.pega.jenkins.plugins:jenkins-pipeline-warehouse-plugin:10.8.6@jar')"

Dependencies defined as below:

dependencies {
     jenkinsPlugins('org.jenkins-ci.plugins.workflow:workflow-aggregator:2.4@jar') {
         transitive = true
     }

     jenkinsPlugins('com.pega.jenkins.plugins:jenkins-pipeline-warehouse-plugin:10.8.6@jar') {
         transitive = true
     }
}

Extracted MANIFEST.MF file from generated HPI file:

Manifest-Version: 1.0
Plugin-Dependencies: workflow-aggregator:2.4,jenkins-pipeline-warehous
 e-plugin:10.8.6
Long-Name: Cache for bugs created for test cases
Group-Id: com.pega.jenkins.plugins
Minimum-Java-Version: 1.8
Plugin-Version: 1.2.4
Jenkins-Version: 2.107.2
Extension-Name: jenkins-test-bugs-cache-plugin
Short-Name: jenkins-test-bugs-cache-plugin

Now, we have upgraded our custom plugin to gradle 7.4.1 and gradle-jpi-plugin version to 0.49.0.

To add the custom jenkins plugin dependency, we are using "implementation('com.pega.jenkins.plugins:jenkins-pipeline-warehouse-plugin:11.1.6-branch-flakyTestAdd-24-SNAPSHOT')" as we dont have the "jenkinsPlugins" option in 0.49.0

Dependencies defined as below:

dependencies {
    implementation('org.jenkins-ci.plugins.workflow:workflow-aggregator:2.5') {
        transitive = true
    }
    implementation('com.pega.jenkins.plugins:jenkins-pipeline-warehouse-plugin:11.1.6-branch-flakyTestAdd-24-SNAPSHOT') {
        transitive = true
    }
}

Extracted MANIFEST.MF file from generated HPI file:

Manifest-Version: 1.0
Plugin-Dependencies: workflow-aggregator:2.5
Group-Id: com.pega.jenkins.plugins
Minimum-Java-Version: 11
Short-Name: jenkins-test-bugs-cache-plugin
Extension-Name: jenkins-test-bugs-cache-plugin
Long-Name: Cache for bugs created for test cases
Jenkins-Version: 2.357
Plugin-Version: 2.0.0-SNAPSHOT (private-2023-10-10T14:04:49Z-vutus)

We have custom implimentation of extension class in dependency Jenkins plugin as shown below

 @Extension
 public class PipelinePubsubBus extends PubsubBus { ... }

With this upgrade(gradle 5.5 to 7.4.1, gradle-jpi-plugin 0.33.0 to 0.49.0), The custom implementation of extension classes are not loading(ExtensionList.lookup gives [])

Logger code line : LOGGER.log(Level.INFO, "ExtensionList.lookup(PubsubBus.class):: " + ExtensionList.lookup(PubsubBus.class).toString()); Jenkins Log: Oct 05, 2023 7:41:37 AM INFO com.pega.pipeline.warehouse.PipelineMessage selectChannel selectChannel ExtensionList.lookup(PubsubBus.class):: []

Expected Results

If you compare the both manifest files, the plugin jenkins-pipeline-warehouse-plugin isn't added under Plugin-Dependencies section.

So the custom implementation of extension classes are not loading.

All the dependency classes should load properly.

Actual Results

With the above change, The custom implementation of extension classes are not loading (ExtensionList.lookup gives [])

Anything else?

No response

sghill commented 1 year ago

Hi @sskrishnav,

I tried to reproduce this, but I don't think jenkins-pipeline-warehouse-plugin is public?

Interesting details here would include:

In any case I'd start with making smaller upgrades to both jpi plugin and Gradle to narrow down where this breaks, since these version jumps represent a few years of development for each component.

This code is responsible for identifying plugins on the configuration, which are then used to build the manifest.

sskrishnav commented 1 year ago

Thanks @sghill

The issue is with bundling the hpi file, Because of that dependency plugins are copied into libs folder of hpi file instead of it as a separate plugin dependency.

We make sure the bundling happening properly

publishing.publications.getByName('mavenDefault') {
        it.pom.packaging  = 'hpi'
}