jenkinsci / jenkinsci/gitlab-branch-source-plugin
GitLabApiException when building a repo with Jenkins Templating Engine configured
- Dominant language
- Java
- Stars
- 134
- Forks
- 113
- PR merge metrics
- No merged PRs in 30d
Description
### Jenkins and plugins versions report
Environment
```text
Jenkins: 2.319.3
OS: Linux - 5.4.0-107-generic
---
ace-editor:1.1
analysis-model-api:10.9.4
ansible:1.1
ansicolor:1.0.1
ant:1.13
antisamy-markup-formatter:2.7
apache-httpcomponents-client-4-api:4.5.13-1.0
artifactory:3.16.1
async-http-client:1.9.40.0
authentication-tokens:1.4
aws-credentials:191.vcb_f183ce58b_9
aws-java-sdk-ec2:1.12.163-315.v2b_716ec8e4df
aws-java-sdk-minimal:1.12.163-315.v2b_716ec8e4df
badge:1.9.1
blueocean:1.25.3
blueocean-autofavorite:1.2.5
blueocean-bitbucket-pipeline:1.25.3
blueocean-commons:1.25.3
blueocean-config:1.25.3
blueocean-core-js:1.25.3
blueocean-dashboard:1.25.3
blueocean-display-url:2.4.1
blueocean-events:1.25.3
blueocean-git-pipeline:1.25.3
blueocean-github-pipeline:1.25.3
blueocean-i18n:1.25.3
blueocean-jira:1.25.3
blueocean-jwt:1.25.3
blueocean-personalization:1.25.3
blueocean-pipeline-api-impl:1.25.3
blueocean-pipeline-editor:1.25.3
blueocean-pipeline-scm-api:1.25.3
blueocean-rest:1.25.3
blueocean-rest-impl:1.25.3
blueocean-web:1.25.3
bootstrap4-api:4.6.0-3
bootstrap5-api:5.1.3-6
bouncycastle-api:2.25
branch-api:2.1044.v2c007e51b_87f
build-blocker-plugin:1.7.8
build-name-setter:2.2.0
build-timeout:1.20
caffeine-api:2.9.2-29.v717aac953ff3
checks-api:1.7.2
cloudbees-bitbucket-branch-source:762.v969cfe087fc0
cloudbees-folder:6.714.v79e858ef76a_2
code-coverage-api:2.0.4
command-launcher:1.6
config-file-provider:3.9.0
configuration-as-code:1414.v878271fc496f
copyartifact:1.46.3
cors-filter:1.1
credentials:1087.1089.v2f1b_9a_b_040e4
credentials-binding:1.27.1
dashboard-view:2.426.vb_93dcdb_b_0eb_0
data-tables-api:1.11.4-4
display-url-api:2.3.5
docker-build-publish:1.3.3
docker-commons:1.19
docker-java-api:3.1.5.2
docker-plugin:1.2.7
docker-traceability:1.2
docker-workflow:1.28
dockerhub-notification:2.6.0
durable-task:495.v29cd95ec10f2
ec2:1.68
echarts-api:5.3.0-2
email-ext:2.87
embeddable-build-status:2.0.3
envinject:2.847.vb_fa_18490fa_d6
envinject-api:1.192.va_13643e71792
extended-choice-parameter:346.vd87693c5a_86c
external-monitor-job:191.v363d0d1efdf8
favorite:2.4.1
font-awesome-api:6.0.0-1
forensics-api:1.12.0
git:4.11.0
git-changelog:3.23
git-client:3.11.0
git-forensics:1.7.0
git-parameter:0.9.16
git-push:34.vd474e0fe7b_ec
git-server:1.10
github:1.34.3
github-api:1.301-378.v9807bd746da5
github-branch-source:2.11.4
gitlab-api:1.0.6
gitlab-branch-source:1.5.10-SNAPSHOT (private-efb7780f-yethal)
gitlab-plugin:1.5.28
google-login:1.6
google-oauth-plugin:1.0.6
gradle:1.38
greenballs:1.15.1
groovy:2.4
groovy-postbuild:2.5
h2-api:1.4.199
handlebars:3.0.8
handy-uri-templates-2-api:2.1.8-1.0
htmlpublisher:1.29
http_request:1.14
ivy:2.1
jackson2-api:2.13.2-260.v43d711474c77
jacoco:3.3.1
javadoc:217.v905b_86277a_2a_
javax-activation-api:1.2.0-2
javax-mail-api:1.6.2-5
jaxb:2.3.0.1
jdk-tool:1.5
jenkins-design-language:1.25.3
jersey2-api:2.35-5
jira:3.7.1
jjwt-api:0.11.2-9.c8b45b8bb173
jnr-posix-api:3.1.7-3
jquery:1.12.4-1
jquery-detached:1.2.1
jquery3-api:3.6.0-2
jsch:0.1.55.2
junit:1.54
kubernetes:3580.v78271e5631dc
kubernetes-cli:1.10.3
kubernetes-client-api:5.12.1-187.v577c3e368fb_6
kubernetes-credentials:0.9.0
locale:144.v1a_998824ddb_3
lockable-resources:2.14
mailer:408.vd726a_1130320
markdown-formatter:0.2.0
matrix-auth:3.1
matrix-project:758.v7a_ea_491852f3
maven-plugin:3.16
metrics:4.1.6.1
minio:1.3.3-rc93.9e92f846d4cf
momentjs:1.1.1
nested-view:1.24
node-iterator-api:1.5.1
oauth-credentials:0.5
okhttp-api:4.9.3-105.vb96869f8ac3a
pam-auth:1.7
parameterized-scheduler:1.0
parameterized-trigger:2.44
pipeline-aggregator-view:1.11
pipeline-build-step:2.17
pipeline-github-lib:36.v4c01db_ca_ed16
pipeline-graph-analysis:188.v3a01e7973f2c
pipeline-input-step:447.v95e5a_6e3502a_
pipeline-maven:3.10.0
pipeline-milestone-step:100.v60a_03cd446e1
pipeline-model-api:1.9.3
pipeline-model-definition:1.9.3
pipeline-model-extensions:1.9.3
pipeline-rest-api:2.23
pipeline-stage-step:291.vf0a8a7aeeb50
pipeline-stage-tags-metadata:1.9.3
pipeline-stage-view:2.23
pipeline-utility-steps:2.12.0
plain-credentials:1.8
plugin-util-api:2.16.0
popper-api:1.16.1-2
popper2-api:2.11.5-1
prism-api:1.26.0-2
promoted-builds:876.v99d29788b_36b_
publish-over:0.22
pubsub-light:1.16
pyenv-pipeline:2.1.2
python:1.3
rebuild:1.33.1
release:2.13
resource-disposer:0.18
role-strategy:3.2.0
run-condition:1.5
scm-api:595.vd5a_df5eb_0e39
script-security:1138.v8e727069a_025
sectioned-view:1.25
slack:608.v19e3b_44b_b_9ff
snakeyaml-api:1.29.1
sonar:2.14
sonar-quality-gates:1.3.1
sse-gateway:1.25
ssh-agent:1.24.1
ssh-credentials:1.19
ssh-slaves:1.806.v2253cedd3295
sshd:3.228.v4c9f9e652c86
structs:308.v852b473a2b8c
templating-engine:2.4
thinBackup:1.10
timestamper:1.17
token-macro:285.vff7645a_56ff0
trilead-api:1.57.v6e90e07157e1
variant:1.4
versionnumber:1.9
warnings-ng:9.11.1
workflow-aggregator:2.7
workflow-api:1143.v2d42f1e9dea_5
workflow-basic-steps:2.24
workflow-cps:2660.vb_c0412dc4e6d
workflow-cps-global-lib:566.vd0a_a_3334a_555
workflow-durable-task-step:1128.v8c259d125340
workflow-job:1145.v7f2433caa07f
workflow-multibranch:711.vdfef37cda_816
workflow-scm-step:2.13
workflow-step-api:622.vb_8e7c15b_c95a_
workflow-support:813.vb_d7c3d2984a_0
ws-cleanup:0.41
```
### What Operating System are you using (both controller, and any agents involved in the problem)?
Ubuntu 20.04 everywhere
### Reproduction steps
1. Install Jenkins Templating Engine plugin on controller
2. Create a repository holding an example Templating Engine library that runs following code:
3. `node {
checkout scm
}`
4. Create an organization folder with Jenkins Templating Engine configured so that both pipeline configuration and libraries are obtained from scm
5. Create a repository within the organization folder with templating engine configuration
6. Run job created by organization folder scan
### Expected Results
Repository is checked out and job runs
### Actual Results
Pipeline config is obtained but when the checkout of actual repo starts following exception is thrown:
```hudson.remoting.ProxyException: java.lang.ClassCastException: Cannot cast org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory to org.glassfish.jersey.internal.inject.InjectionManagerFactory
at java.base/java.lang.Class.cast(Class.java:3605)
at org.glassfish.jersey.internal.ServiceFinder$LazyObjectIterator.hasNext(ServiceFinder.java:690)
at org.glassfish.jersey.internal.inject.Injections.lookupService(Injections.java:88)
at org.glassfish.jersey.internal.inject.Injections.lookupInjectionManagerFactory(Injections.java:73)
at org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:44)
at org.glassfish.jersey.client.ClientConfig$State.initRuntime(ClientConfig.java:412)
at org.glassfish.jersey.internal.util.collection.Values$LazyValueImpl.get(Values.java:317)
at org.glassfish.jersey.client.ClientConfig.getRuntime(ClientConfig.java:807)
at org.glassfish.jersey.client.ClientRequest.getClientRuntime(ClientRequest.java:219)
at org.glassfish.jersey.client.ClientRequest.getInjectionManager(ClientRequest.java:610)
at org.glassfish.jersey.client.JerseyWebTarget.onBuilder(JerseyWebTarget.java:364)
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:192)
at org.glassfish.jersey.client.JerseyWebTarget.request(JerseyWebTarget.java:36)
at org.gitlab4j.api.GitLabApiClient.invocation(GitLabApiClient.java:783)
at org.gitlab4j.api.GitLabApiClient.invocation(GitLabApiClient.java:748)
at org.gitlab4j.api.GitLabApiClient.get(GitLabApiClient.java:399)
at org.gitlab4j.api.GitLabApiClient.get(GitLabApiClient.java:387)
at org.gitlab4j.api.AbstractApi.get(AbstractApi.java:213)
Caused: hudson.remoting.ProxyException: org.gitlab4j.api.GitLabApiException: Cannot cast org.glassfish.jersey.inject.hk2.Hk2InjectionManagerFactory to org.glassfish.jersey.internal.inject.InjectionManagerFactory
at org.gitlab4j.api.AbstractApi.handle(AbstractApi.java:655)
at org.gitlab4j.api.AbstractApi.get(AbstractApi.java:215)
at org.gitlab4j.api.RepositoryApi.getBranch(RepositoryApi.java:104)
at io.jenkins.plugins.gitlabbranchsource.GitLabSCMSource.retrieve(GitLabSCMSource.java:258)
at jenkins.scm.api.SCMSource.fetch(SCMSource.java:582)
at org.jenkinsci.plugins.workflow.multibranch.SCMVar.getValue(SCMVar.java:104)
at org.jenkinsci.plugins.workflow.multibranch.SCMVar.getValue(SCMVar.java:59)
at org.jenkinsci.plugins.workflow.cps.CpsScript.getProperty(CpsScript.java:135)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:174)
at groovy.lang.Closure.getPropertyTryThese(Closure.java:312)
at groovy.lang.Closure.getPropertyOwnerFirst(Closure.java:306)
at groovy.lang.Closure.getProperty(Closure.java:295)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:174)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:456)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.getProperty(DefaultInvoker.java:39)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
Caused: hudson.remoting.ProxyException: java.io.IOException: Failed to retrieve the SCM revision for master
at io.jenkins.plugins.gitlabbranchsource.GitLabSCMSource.retrieve(GitLabSCMSource.java:298)
at jenkins.scm.api.SCMSource.fetch(SCMSource.java:582)
at org.jenkinsci.plugins.workflow.multibranch.SCMVar.getValue(SCMVar.java:104)
at org.jenkinsci.plugins.workflow.multibranch.SCMVar.getValue(SCMVar.java:59)
at org.jenkinsci.plugins.workflow.cps.CpsScript.getProperty(CpsScript.java:135)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:174)
at groovy.lang.Closure.getPropertyTryThese(Closure.java:312)
at groovy.lang.Closure.getPropertyOwnerFirst(Closure.java:306)
at groovy.lang.Closure.getProperty(Closure.java:295)
at org.codehaus.groovy.runtime.InvokerHelper.getProperty(InvokerHelper.java:174)
at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.getProperty(ScriptBytecodeAdapter.java:456)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.getProperty(DefaultInvoker.java:39)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.call(WorkflowScript:4)
at ___cps.transform___(Native Method)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.get(PropertyishBlock.java:74)
at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
at com.cloudbees.groovy.cps.impl.PropertyishBlock$ContinuationImpl.fixName(PropertyishBlock.java:66)
at jdk.internal.reflect.GeneratedMethodAccessor308.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.ConstantBlock.eval(ConstantBlock.java:21)
Caused: hudson.remoting.ProxyException: org.codehaus.groovy.runtime.InvokerInvocationException: java.io.IOException: Failed to retrieve the SCM revision for master
at org.boozallen.plugins.jte.init.primitives.hooks.AnnotatedMethod.invoke(AnnotatedMethod.groovy:55)
at org.boozallen.plugins.jte.init.primitives.hooks.Hooks.invoke(script16507496975591835893780.groovy:60)
at com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods:2030)
at com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods:2015)
at com.cloudbees.groovy.cps.CpsDefaultGroovyMethods.each(CpsDefaultGroovyMethods:2056)
at org.boozallen.plugins.jte.init.primitives.hooks.Hooks.invoke(script16507496975591835893780.groovy:58)
at org.boozallen.plugins.jte.init.primitives.hooks.Hooks.invoke(script16507496975591835893780.groovy)
at WorkflowScript.run(WorkflowScript)
at ___cps.transform___(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCallConstructor(CallSiteArray.java:60)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:235)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.constructorCall(DefaultInvoker.java:25)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.dispatchOrArg(FunctionCallBlock.java:97)
at com.cloudbees.groovy.cps.impl.FunctionCallBlock$ContinuationImpl.fixArg(FunctionCallBlock.java:83)
at jdk.internal.reflect.GeneratedMethodAccessor300.invoke(Unknown Source)
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.base/java.lang.reflect.Method.invoke(Method.java:566)
at com.cloudbees.groovy.cps.impl.ContinuationPtr$ContinuationImpl.receive(ContinuationPtr.java:72)
at com.cloudbees.groovy.cps.impl.LocalVariableBlock$LocalVariable.get(LocalVariableBlock.java:39)
at com.cloudbees.groovy.cps.LValueBlock$GetAdapter.receive(LValueBlock.java:30)
at com.cloudbees.groovy.cps.impl.LocalVariableBlock.evalLValue(LocalVariableBlock.java:28)
at com.cloudbees.groovy.cps.LValueBlock$BlockImpl.eval(LValueBlock.java:55)
at com.cloudbees.groovy.cps.LValueBlock.eval(LValueBlock.java:16)
at com.cloudbees.groovy.cps.Next.step(Next.java:83)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:174)
at com.cloudbees.groovy.cps.Continuable$1.call(Continuable.java:163)
at org.codehaus.groovy.runtime.GroovyCategorySupport$ThreadCategoryInfo.use(GroovyCategorySupport.java:129)
at org.codehaus.groovy.runtime.GroovyCategorySupport.use(GroovyCategorySupport.java:268)
at com.cloudbees.groovy.cps.Continuable.run0(Continuable.java:163)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.access$001(SandboxContinuable.java:18)
at org.jenkinsci.plugins.workflow.cps.SandboxContinuable.run0(SandboxContinuable.java:51)
at org.jenkinsci.plugins.workflow.cps.CpsThread.runNextChunk(CpsThread.java:185)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.run(CpsThreadGroup.java:403)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup.access$400(CpsThreadGroup.java:97)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:315)
at org.jenkinsci.plugins.workflow.cps.CpsThreadGroup$2.call(CpsThreadGroup.java:279)
at org.jenkinsci.plugins.workflow.cps.CpsVmExecutorService$2.call(CpsVmExecutorService.java:67)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
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 java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at java.base/java.lang.Thread.run(Thread.java:829)
```
### Anything else?
If `checkout scm` is put inside try catch block then the rest of the code runs without issues
Contributor guide
Assessment
This issue has not been assessed yet.