jenkinsci / bitbucket-branch-source-plugin

Bitbucket Branch Source Plugin
https://plugins.jenkins.io/cloudbees-bitbucket-branch-source
MIT License
216 stars 351 forks source link

Bitbucket SCM do not manage scm object properties due to java.lang.ClassNotFoundException: org.apache.logging.log4j.spi.LoggerAdapter #903

Open MoNaX667 opened 21 hours ago

MoNaX667 commented 21 hours ago

Jenkins and plugins versions report

Jenkins: 2.462.3 OS: Linux - 5.4.0-100-generic Java: 17.0.12 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)

ace-editor:1.1 active-directory:2.37 allure-jenkins:3.29.2 allure-jenkins-plugin:2.31.1 ansible:253.v4fe719ffdd8a_ ansible-tower:0.16.0 ansicolor:1.0.2 antisamy-markup-formatter:162.v0e6ec0fcfcf6 apache-httpcomponents-client-4-api:4.5.14-208.v438351942757 apache-httpcomponents-client-5-api:5.4-124.v31e2987e48f4 asm-api:9.7.1-97.v4cc844130d97 atlassian-bitbucket-server-integration:4.1.1 audit-trail:333.vb_e1b_b_0f1238c authentication-tokens:1.119.v50285141b_7e1 basic-branch-build-strategies:1.3.2 bootstrap5-api:5.3.3-1 bouncycastle-api:2.30.1.78.1-248.ve27176eb46cb branch-api:2.1178.v969d9eb_c728e build-token-root:151.va_e52fe3215fc build-with-parameters:76.v9382db_f78962 buildresult-trigger:0.18 caffeine-api:3.1.8-133.v17b_1ff2e0599 checks-api:2.0.2 cloudbees-bitbucket-branch-source:895.v15dc41668f03 cloudbees-disk-usage-simple:205.v47f4ee8803d1 cloudbees-folder:6.942.vb_43318a_156b_2 cobertura:1.17 code-coverage-api:4.0.3 command-launcher:90.v669d7ccb_7c31 commons-compress-api:1.26.1-2 commons-httpclient3-api:3.1-3 commons-lang3-api:3.14.0-76.vda_5591261cfe commons-text-api:1.12.0-129.v99a_50df237f7 configuration-as-code:1873.vea_5814ca_9c93 configuration-as-code-groovy:1.1 copyartifact:686.v6fd37018d7c2 credentials:1378.v81ef4269d764 credentials-binding:681.vf91669a_32e45 custom-tools-plugin:0.8 data-tables-api:2.1.6-1 display-url-api:2.204.vf6fddd8a_8b_e9 docker-commons:439.va_3cb_0a_6a_fb_29 docker-java-api:3.4.0-94.v65ced49b_a_7d5 docker-workflow:563.vd5d2e5c4007f durable-task:577.v2a_8a_4b_7c0247 echarts-api:5.4.0-7 email-ext:2.95 envinject:2.901.v0038b_6471582 envinject-api:1.199.v3ce31253ed13 extended-choice-parameter:359.v35dcfdd0c20d font-awesome-api:6.5.2-1 forensics-api:2.1.0 gatling:1.3.0 generic-webhook-trigger:1.86.2 git:5.5.2 git-client:5.0.0 git-parameter:0.10.0 gradle:2.3.2 gson-api:2.11.0-85.v1f4e87273c33 handlebars:3.0.8 handy-uri-templates-2-api:2.1.8-30.v7e777411b_148 hashicorp-vault-plugin:360.v0a_1c04cf807d htmlpublisher:1.31 http_request:1.16 instance-identity:185.v303dc7c645f9 ionicons-api:74.v93d5eb_813d5f jackson2-api:2.17.0-379.v02de8ec9f64c jacoco:3.3.3 jakarta-activation-api:2.1.3-1 jakarta-mail-api:2.1.3-1 javax-activation-api:1.2.0-6 javax-mail-api:1.6.2-9 jaxb:2.3.9-1 jdk-tool:63.v62d2fd4b_4793 jenkins-plugin:3.14.6 job-dsl:1.89 jobConfigHistory:1207.vd28a_54732f92 joda-time-api:2.13.0-93.v9934da_29b_a_e9 jquery:1.12.4-1 jquery3-api:3.7.1-2 jsch:0.1.55.61.va_e9ee26616e7 json-api:20240303-41.v94e11e6de726 json-path-api:2.9.0-118.v7f23ed82a_8b_8 junit:1265.v65b_14fa_f12f0 kubernetes:4295.v7fa_01b_309c95 kubernetes-client-api:6.10.0-240.v57880ce8b_0b_2 kubernetes-credentials:0.11 ldap:725.v3cb_b_711b_1a_ef lockable-resources:1327.ved786b_a_197e0 mailer:488.v0c9639c1a_eb_3 matrix-auth:3.1.6 matrix-project:838.v4d7b_7b_f9bd4b metrics:4.2.21-449.v6960d7c54c69 mina-sshd-api-common:2.14.0-133.vcc091215a_358 mina-sshd-api-core:2.14.0-133.vcc091215a_358 momentjs:1.1.1 nexus-artifact-uploader:2.14 okhttp-api:4.11.0-157.v6852a_a_fa_ec11 parameter-separator:1.3 parameterized-scheduler:1.2 pipeline-build-step:540.vb_e8849e1a_b_d8 pipeline-graph-analysis:202.va_d268e64deb_3 pipeline-groovy-lib:744.v5b_556ee7c253 pipeline-input-step:477.v339683a_8d55e pipeline-milestone-step:111.v449306f708b_7 pipeline-model-api:2.2214.vb_b_34b_2ea_9b_83 pipeline-model-definition:2.2214.vb_b_34b_2ea_9b_83 pipeline-model-extensions:2.2214.vb_b_34b_2ea_9b83 pipeline-rest-api:2.32 pipeline-stage-step:312.v8cd10304c27a pipeline-stage-tags-metadata:2.2214.vb_b_34b_2ea_9b_83 pipeline-stage-view:2.32 pipeline-utility-steps:2.18.0 plain-credentials:183.va_de8f1dd5a2b plugin-util-api:4.1.0 popper2-api:2.11.6-2 prism-api:1.29.0-17 prometheus:2.1.2 rebuild:332.va_1ee476d8f6d remote-file:1.24 resource-disposer:0.21 role-strategy:587.588.v850a_20a_30162 schedule-build:550.v8eb_e2fcf7b_1c scm-api:696.v778d637b_a762 script-security:1367.vdf2fc45f229c snakeyaml-api:2.3-123.v13484c65210a ssh:2.6.1 ssh-credentials:343.v884f71d78167 ssh-slaves:2.877.v365f5eb_a_b_eec ssh-steps:2.0.65.vd26b_5b_9b_de4d sshd:3.275.v9e17c10f2571 stashNotifier:1.28 strict-crumb-issuer:2.1.1 structs:338.v848422169819 token-macro:400.v35420b922dcb trilead-api:2.142.v748523a_76693 uno-choice:2.6.4 variant:60.v7290fc0eb_b_cd windows-slaves:1.8.1 workflow-aggregator:600.vb_57cdd26fdd7 workflow-api:1322.v857eeeea_9902 workflow-basic-steps:1058.vcb_fc1e3a_21a_9 workflow-cps:3990.vd281dd77a_388 workflow-durable-task-step:1331.vc8c2fed35334 workflow-job:1436.vfa_244484591f workflow-multibranch:795.ve0cb_1f45ca9a workflow-scm-step:427.v4ca_6512e7df1 workflow-step-api:678.v3ee58b_469476 workflow-support:930.vf51d22b_ce488 ws-cleanup:0.44

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

PRETTY_NAME="Debian GNU/Linux 12 (bookworm)" NAME="Debian GNU/Linux" VERSION_ID="12" VERSION="12 (bookworm)" VERSION_CODENAME=bookworm ID=debian HOME_URL="https://www.debian.org/" SUPPORT_URL="https://www.debian.org/support" BUG_REPORT_URL="https://bugs.debian.org/"

Reproduction steps

  1. Create multi branch pipeline with scm-bitbucket source
  2. Create a jenkins file with checkout stage inside. It should have references to scm object with calling relevant properties branches, extensions, userRemoteConfigs.

for example:

stage('Checkout') { checkout([ $class: 'GitSCM', branches: scm.branches, doGenerateSubmoduleConfigurations: true, extensions: scm.extensions + [[$class: 'SubmoduleOption', parentCredentials: true]], userRemoteConfigs: scm.userRemoteConfigs ]) }

  1. Call pipeline

Expected Results

Checkout stage pass with receiving target scm objects's properties like:

Actual Results

Checkout stage fails on getting scm.* object's properties due to next exception:

java.lang.ClassNotFoundException: org.apache.logging.log4j.spi.LoggerAdapter at java.base/java.net.URLClassLoader.findClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) at java.base/java.lang.ClassLoader.loadClass(Unknown Source) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Unknown Source) at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:419) at org.apache.commons.logging.LogFactory.lambda$newFactory$3(LogFactory.java:1431) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:1431) at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:928) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:987) at org.apache.http.impl.client.BasicAuthCache.(BasicAuthCache.java:63) at org.apache.http.impl.client.BasicAuthCache.(BasicAuthCache.java:81) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.api.credentials.BitbucketUsernamePasswordAuthenticator.configureContext(BitbucketUsernamePasswordAuthenticator.java:74) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getHttpClient(BitbucketServerAPIClient.java:1067) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:962) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:953) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getResource(BitbucketServerAPIClient.java:930) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getSingleBranch(BitbucketServerAPIClient.java:655) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getBranch(BitbucketServerAPIClient.java:605) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getBranch(BitbucketServerAPIClient.java:133) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieve(BitbucketSCMSource.java:920) at PluginClassLoader for scm-api//jenkins.scm.api.SCMSource.fetch(SCMSource.java:581) at PluginClassLoader for workflow-multibranch//org.jenkinsci.plugins.workflow.multibranch.SCMVar.getValue(SCMVar.java:104) at PluginClassLoader for workflow-multibranch//org.jenkinsci.plugins.workflow.multibranch.SCMVar.getValue(SCMVar.java:59) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsScript.getProperty(CpsScript.java:137) at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:190) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:469) at PluginClassLoader for script-security//org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:377) at PluginClassLoader for script-security//org.kohsuke.groovy.sandbox.GroovyInterceptor.onGetProperty(GroovyInterceptor.java:68) at PluginClassLoader for script-security//org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:347) at PluginClassLoader for script-security//org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:375) at PluginClassLoader for script-security//org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:379) at PluginClassLoader for script-security//org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:355) at PluginClassLoader for script-security//org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:355) at PluginClassLoader for script-security//org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:355) at PluginClassLoader for workflow-cps//com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.LoggingInvoker.getProperty(LoggingInvoker.java:133) at PluginClassLoader for workflow-cps//com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20) Also: org.jenkinsci.plugins.workflow.actions.ErrorAction$ErrorId: 7a46ef41-3627-4aab-a6f9-263b690090ca Caused: java.lang.NoClassDefFoundError: org/apache/logging/log4j/spi/LoggerAdapter at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Unknown Source) at org.apache.commons.logging.LogFactory.createFactory(LogFactory.java:419) at org.apache.commons.logging.LogFactory.lambda$newFactory$3(LogFactory.java:1431) at java.base/java.security.AccessController.doPrivileged(Unknown Source) at org.apache.commons.logging.LogFactory.newFactory(LogFactory.java:1431) at org.apache.commons.logging.LogFactory.getFactory(LogFactory.java:928) at org.apache.commons.logging.LogFactory.getLog(LogFactory.java:987) at org.apache.http.impl.client.BasicAuthCache.(BasicAuthCache.java:63) at org.apache.http.impl.client.BasicAuthCache.(BasicAuthCache.java:81) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.api.credentials.BitbucketUsernamePasswordAuthenticator.configureContext(BitbucketUsernamePasswordAuthenticator.java:74) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getHttpClient(BitbucketServerAPIClient.java:1067) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:962) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getRequest(BitbucketServerAPIClient.java:953) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getResource(BitbucketServerAPIClient.java:930) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getSingleBranch(BitbucketServerAPIClient.java:655) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getBranch(BitbucketServerAPIClient.java:605) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.server.client.BitbucketServerAPIClient.getBranch(BitbucketServerAPIClient.java:133) at PluginClassLoader for cloudbees-bitbucket-branch-source//com.cloudbees.jenkins.plugins.bitbucket.BitbucketSCMSource.retrieve(BitbucketSCMSource.java:920) at PluginClassLoader for scm-api//jenkins.scm.api.SCMSource.fetch(SCMSource.java:581) at PluginClassLoader for workflow-multibranch//org.jenkinsci.plugins.workflow.multibranch.SCMVar.getValue(SCMVar.java:104) at PluginClassLoader for workflow-multibranch//org.jenkinsci.plugins.workflow.multibranch.SCMVar.getValue(SCMVar.java:59) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsScript.getProperty(CpsScript.java:137) at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:190) at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:469) at PluginClassLoader for script-security//org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:377) at PluginClassLoader for script-security//org.kohsuke.groovy.sandbox.GroovyInterceptor.onGetProperty(GroovyInterceptor.java:68) at PluginClassLoader for script-security//org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:347) at PluginClassLoader for script-security//org.kohsuke.groovy.sandbox.impl.Checker$7.call(Checker.java:375) at PluginClassLoader for script-security//org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:379) at PluginClassLoader for script-security//org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:355) at PluginClassLoader for script-security//org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:355) at PluginClassLoader for script-security//org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:355) at PluginClassLoader for workflow-cps//com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.LoggingInvoker.getProperty(LoggingInvoker.java:133) at PluginClassLoader for workflow-cps//com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20) at WorkflowScript.run(WorkflowScript:55) at cps.transform(Native Method) at PluginClassLoader for workflow-cps//com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:73) at PluginClassLoader for workflow-cps//com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30) at PluginClassLoader for workflow-cps//com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:65) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at PluginClassLoader for workflow-cps//com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72) at PluginClassLoader for workflow-cps//com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21) at PluginClassLoader for workflow-cps//com.cloudbees.groovy.cps.Next.step(Next.java:83) at PluginClassLoader for workflow-cps//com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:147) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:17) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:49) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:180) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:422) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:330) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:294) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService.lambda$wrap$4(CpsVmExecutorService.java:140) at java.base/java.util.concurrent.FutureTask.run(Unknown Source) at hudson.remoting.SingleLaneExecutorService$1.run(SingleLaneExecutorService.java:139) at jenkins.util.ContextResettingExecutorService$1.run(ContextResettingExecutorService.java:28) at jenkins.security.ImpersonatingExecutorService$1.run(ImpersonatingExecutorService.java:68) at jenkins.util.ErrorLoggingExecutorService.lambda$wrap$0(ErrorLoggingExecutorService.java:51) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) at java.base/java.util.concurrent.FutureTask.run(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.call(CpsVmExecutorService.java:53) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$1.call(CpsVmExecutorService.java:50) at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:136) at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:275) at PluginClassLoader for workflow-cps//org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService.lambda$categoryThreadFactory$0(CpsVmExecutorService.java:50) at java.base/java.lang.Thread.run(Unknown Source) Finished: FAILURE

Anything else?

The affected scenario works as expected with usage a git source instead of bitbucket provided by cloudbees-bitbucket-branch-source plugin.

There is a part of relevant JJB config:

(affected) scm:

(working) scm:

Are you interested in contributing a fix?

No response

nfalco79 commented 13 hours ago

That depends come from plugin-pom parent and it is marked as provided. In the plugin classpath works because it depends on apache-httpcomponents-client-4-api in a pipeline script I do not know. @jglick do you know why commons-logging in org.jenkins-ci.plugins:plugin:4.88 has been marked as provided?

basil commented 11 hours ago

@nfalco79 No good reason: see https://github.com/jenkinsci/plugin-pom/issues/676.

jglick commented 10 hours ago

BTW it is prudent to have at least one smoke test using RealJenkinsRule which will normally catch issues like this.

nfalco79 commented 10 hours ago

Since 2023 the issue is open I suppose I should have to redeclare in my pom.xml commons-logging with compile scope. The problem is that I have to add also if that commons-logging should come from apache http client api plugi (or maybe is also provided there). In this way I could have commons-loggins twice in the plugin classpath. Mhm .....