jenkinsci / templating-engine-plugin

create tool-agnostic, templated pipelines to be shared by multiple teams
https://jenkinsci.github.io/templating-engine-plugin/latest/
Apache License 2.0
171 stars 59 forks source link

[Bug]: java.lang.Exception: Could not determine pipeline template on Pull Request only #331

Open hejech opened 11 months ago

hejech commented 11 months ago

Jenkins Version

2.401.1

JTE Version

2.5.3

Bug Description

I get a java.lang.Exception when starting a pipeline on a pull request. On other branches the pipeline works fine.

Relevant log output

08:04:36  [JTE] FileSystemWrapperFactory: Unable to create SCMFileSystem: job: build-arkv-bff-api-v1-jte/PR-167, scm: null
08:04:38  [JTE] FileSystemWrapperFactory: Unable to create SCMFileSystem: job: build-arkv-bff-api-v1-jte/PR-167, scm: null
08:04:38  java.lang.Exception: Could not determine pipeline template.
08:04:38    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
08:04:38    at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
08:04:38    at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
08:04:38    at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490)
08:04:38    at org.codehaus.groovy.reflection.CachedConstructor.invoke(CachedConstructor.java:83)
08:04:38    at org.codehaus.groovy.runtime.callsite.ConstructorSite$ConstructorSiteNoUnwrapNoCoerce.callConstructor(ConstructorSite.java:105)
08:04:38    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callConstructor(AbstractCallSite.java:250)
08:04:38    at org.boozallen.plugins.jte.init.PipelineTemplateResolver.resolve(PipelineTemplateResolver.groovy:79)
08:04:38    at org.boozallen.plugins.jte.init.PipelineTemplateResolver$resolve.call(Unknown Source)
08:04:38    at org.boozallen.plugins.jte.job.TemplateFlowDefinition.create(TemplateFlowDefinition.groovy:80)
08:04:38    at org.jenkinsci.plugins.workflow.job.WorkflowRun.run(WorkflowRun.java:312)
08:04:38    at hudson.model.ResourceController.execute(ResourceController.java:101)
08:04:38    at hudson.model.Executor.run(Executor.java:442)
08:04:38  Finished: FAILURE

Steps to Reproduce

Can be reproduced by starting the pipeline manually on the pull request

Additional Info

If I add a Pipeline Config )content of Jenkinsfile) directly to the Jenkins Pipeline Configuration, then it works for PRs also.

Jmelendez93 commented 10 months ago

This happens for me with Bitbucket when using Discover pull requests from origin set to Merging the pull request with the current target branch revision. Changing it to The current pull request revision makes the issue go away, though the downside there is the code is not in a merged state, so presumably it requires everyone to be merging the target branch into their feature branch (which is a good practice, but not necessarily an assumption we can make for every developer).