[JIRA] (JENKINS-60321) Multibranch pipeline with default Jenkinsfile fails when scanning p4 streams

27 views
Skip to first unread message

mbrunton@eidosmontreal.com (JIRA)

unread,
Nov 28, 2019, 11:49:03 AM11/28/19
to jenkinsc...@googlegroups.com
Matthew Brunton created an issue
 
Jenkins / Bug JENKINS-60321
Multibranch pipeline with default Jenkinsfile fails when scanning p4 streams
Issue Type: Bug Bug
Assignee: Unassigned
Components: p4-plugin
Created: 2019-11-28 16:48
Environment: Docker image jenkins/jenkins:2.190.3 in a docker network with a Perforce instance (https://github.com/p4paul/helix-docker) using p4-plugin 1.10.7 and
Pipeline: Multibranch with defaults 2.1
Priority: Blocker Blocker
Reporter: Matthew Brunton

When using the p4 plugin and the Pipeline: Multibranch with defaults plugin, scanning a multibranch pipeline with a default Jenkinsfile results in a java.lang.ClassCastException.

To reproduce, I used the jenkins/jenkins:2.190.3 docker image of Jenkins with p4-plugin (1.10.3) and the Pipeline: Multibranch with defaults plugin (2.1), as well as a clean docker instance of Perforce (https://github.com/p4paul/helix-docker). I created a stream depot with a couple of dummy streams to use for tests.

I created a new multibranch pipeline, set up the Branch source to be the p4 depot with the dummy streams, and set the Build configuration to use by default Jenkinsfile.

It results in the following output:

Started by user admin
[Thu Nov 28 16:40:12 UTC 2019] Starting branch indexing...
... p4 streams //testDepot/... +ERROR: [Thu Nov 28 16:40:12 UTC 2019] Could not fetch branches from source f9f7c9b6-5fe3-4b7b-bec1-b56ed976ef85
java.lang.ClassCastException: org.jenkinsci.plugins.pipeline.multibranch.defaults.PipelineBranchDefaultsProjectFactory cannot be cast to org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory
	at org.jenkinsci.plugins.p4.scm.AbstractP4ScmSource.getLastScan(AbstractP4ScmSource.java:383)
	at org.jenkinsci.plugins.p4.scm.AbstractP4ScmSource.getRevision(AbstractP4ScmSource.java:310)
	at org.jenkinsci.plugins.p4.scm.AbstractP4ScmSource.retrieve(AbstractP4ScmSource.java:158)
Caused: java.io.IOException
	at org.jenkinsci.plugins.p4.scm.AbstractP4ScmSource.retrieve(AbstractP4ScmSource.java:194)
	at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373)
	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:283)
	at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:635)
	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277)
	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:164)
	at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1026)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)
[Thu Nov 28 16:40:12 UTC 2019] Finished branch indexing. Indexing took 92 ms
FATAL: Failed to recompute children of testMultibranchDefaults2
java.io.IOException: java.lang.ClassCastException: org.jenkinsci.plugins.pipeline.multibranch.defaults.PipelineBranchDefaultsProjectFactory cannot be cast to org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory
	at org.jenkinsci.plugins.p4.scm.AbstractP4ScmSource.retrieve(AbstractP4ScmSource.java:194)
	at jenkins.scm.api.SCMSource._retrieve(SCMSource.java:373)
	at jenkins.scm.api.SCMSource.fetch(SCMSource.java:283)
	at jenkins.branch.MultiBranchProject.computeChildren(MultiBranchProject.java:635)
	at com.cloudbees.hudson.plugins.folder.computed.ComputedFolder.updateChildren(ComputedFolder.java:277)
	at com.cloudbees.hudson.plugins.folder.computed.FolderComputation.run(FolderComputation.java:164)
	at jenkins.branch.MultiBranchProject$BranchIndexing.run(MultiBranchProject.java:1026)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:429)
Caused by: java.lang.ClassCastException: org.jenkinsci.plugins.pipeline.multibranch.defaults.PipelineBranchDefaultsProjectFactory cannot be cast to org.jenkinsci.plugins.workflow.multibranch.WorkflowBranchProjectFactory
	at org.jenkinsci.plugins.p4.scm.AbstractP4ScmSource.getLastScan(AbstractP4ScmSource.java:383)
	at org.jenkinsci.plugins.p4.scm.AbstractP4ScmSource.getRevision(AbstractP4ScmSource.java:310)
	at org.jenkinsci.plugins.p4.scm.AbstractP4ScmSource.retrieve(AbstractP4ScmSource.java:158)
	... 8 more
Finished: FAILURE

Changing the Build configuration back to by Jenkinsfile, the pipeline scans without error.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

mbrunton@eidosmontreal.com (JIRA)

unread,
Nov 28, 2019, 11:55:03 AM11/28/19
to jenkinsc...@googlegroups.com
Matthew Brunton updated an issue
Change By: Matthew Brunton
When using the *p4* plugin and the *Pipeline:* *Multibranch with defaults* plugin, scanning a multibranch pipeline with a default Jenkinsfile results in a _java.lang.ClassCastException._

To reproduce, I used the jenkins/jenkins:2.190.3 docker image of Jenkins with p4-plugin (1.10.
3 7 ) and the Pipeline: Multibranch with defaults plugin (2.1), as well as a clean docker instance of Perforce ([https://github.com/p4paul/helix-docker]). I created a stream depot with a couple of dummy streams to use for tests.

I created a new multibranch pipeline, set up the Branch source to be the p4 depot with the dummy streams, and set the Build configuration to use _by default Jenkinsfile._


It results in the following output:
{code:java}
{code}
Changing the Build configuration back to _by Jenkinsfile_, the pipeline scans without error.

kwirth@perforce.com (JIRA)

unread,
Nov 29, 2019, 4:58:03 AM11/29/19
to jenkinsc...@googlegroups.com
Karl Wirth updated an issue
Change By: Karl Wirth
Attachment: image-2019-11-29-09-57-09-433.png

kwirth@perforce.com (JIRA)

unread,
Nov 29, 2019, 4:59:03 AM11/29/19
to jenkinsc...@googlegroups.com
Karl Wirth commented on Bug JENKINS-60321
 
Re: Multibranch pipeline with default Jenkinsfile fails when scanning p4 streams

Hi Matthew Brunton - Thanks for reporting this.

 

Can you explain where 'default Jenkinsfile' comes from? On my new install I just get 'by Jenkinsfile'?

Do you have an extra plugin installed that adds the extra option or am I misunderstanding your problem description?

 

As you mention, I don't see a crash if 'by Jenkinsfile' is selected.

kwirth@perforce.com (JIRA)

unread,
Nov 29, 2019, 5:04:03 AM11/29/19
to jenkinsc...@googlegroups.com

kwirth@perforce.com (JIRA)

unread,
Nov 29, 2019, 5:04:03 AM11/29/19
to jenkinsc...@googlegroups.com

kwirth@perforce.com (JIRA)

unread,
Nov 29, 2019, 5:06:03 AM11/29/19
to jenkinsc...@googlegroups.com
Karl Wirth updated an issue
Change By: Karl Wirth
Comment: Hi [~mbrunton27] - Thanks for reporting this.


 

Can you explain where 'default Jenkinsfile' comes from? On my new install I just get 'by Jenkinsfile'?

!image-2019-11-29-09-57-09-433.png!


Do you have an extra plugin installed that adds the extra option or am I misunderstanding your problem description?

 

As you mention, I don't see a crash if 'by Jenkinsfile' is selected.

kwirth@perforce.com (JIRA)

unread,
Nov 29, 2019, 5:26:02 AM11/29/19
to jenkinsc...@googlegroups.com

kwirth@perforce.com (JIRA)

unread,
Nov 29, 2019, 5:26:03 AM11/29/19
to jenkinsc...@googlegroups.com
 
Re: Multibranch pipeline with default Jenkinsfile fails when scanning p4 streams

Hi Matthew Brunton  - Ignore last deleted comment - didn't read the report properly.

Thanks for highlighting this. I see the same problem.

When we search for branches we are looking for 'Jenkinsfile' in each branch/stream. If that is not there our detection will fail.  To allow this plugin to work we would need to rewrite the way we do branch detection, so at this time  I don't think we support this plugin.

I will therefore pass this onto the developers as an enhancement request.

For developers - from plugin readme https://github.com/jenkinsci/pipeline-multibranch-defaults-plugin/blob/master

Normally, Jenkins pipelines and Multibranch pipelines requires a developer to save a Jenkinsfile in their repository root on one or more branches. The Pipeline Multibranch Defaults Plugin allows a Jenkins administrator to specify a default Jenkinsfile so that developers do not need to have a Jenkinsfile in their repository.

 

kwirth@perforce.com (JIRA)

unread,
Nov 29, 2019, 5:26:03 AM11/29/19
to jenkinsc...@googlegroups.com

pallen@perforce.com (JIRA)

unread,
Nov 29, 2019, 5:52:04 AM11/29/19
to jenkinsc...@googlegroups.com
Paul Allen commented on Improvement JENKINS-60321
 
Re: Multibranch pipeline with default Jenkinsfile fails when scanning p4 streams

Notes (to avoid exception and ignore Multibranch with defaults): 

 - In AbstractP4ScmSource method getLastScan() check instance of branchProject.getProjectFactory()

 - In AbstractP4ScmSource method retrieve() null check revision and continue loop to next P4SCMHead 

kwirth@perforce.com (JIRA)

unread,
Dec 5, 2019, 4:52:02 AM12/5/19
to jenkinsc...@googlegroups.com

kwirth@perforce.com (JIRA)

unread,
Dec 5, 2019, 4:52:03 AM12/5/19
to jenkinsc...@googlegroups.com

msmeeth@perforce.com (JIRA)

unread,
Dec 11, 2019, 9:56:03 AM12/11/19
to jenkinsc...@googlegroups.com

msmeeth@perforce.com (JIRA)

unread,
Dec 11, 2019, 9:59:03 AM12/11/19
to jenkinsc...@googlegroups.com
Matthew Smeeth started work on Improvement JENKINS-60321
 
Change By: Matthew Smeeth
Status: Open In Progress

msmeeth@perforce.com (JIRA)

unread,
Dec 11, 2019, 9:59:04 AM12/11/19
to jenkinsc...@googlegroups.com

msmeeth@perforce.com (JIRA)

unread,
Dec 17, 2019, 10:40:03 AM12/17/19
to jenkinsc...@googlegroups.com
Matthew Smeeth resolved as Fixed
 

Fixed, it should now use the default Jenkinsfile when using the Multibranch with defaults plugin.

Change By: Matthew Smeeth
Status: In Progress Resolved
Resolution: Fixed

cbopardikar@perforce.com (JIRA)

unread,
Jan 8, 2020, 10:58:04 AM1/8/20
to jenkinsc...@googlegroups.com

cbopardikar@perforce.com (JIRA)

unread,
Jan 8, 2020, 10:59:03 AM1/8/20
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages