Custom Project Recognisers for Jenkins Multi-branch Pipelines Custom Project Recognisers for Jenkins Multi-branch Pipelines jenkins jenkins

Custom Project Recognisers for Jenkins Multi-branch Pipelines


I think you can do that with providing several Project Recognizers with different names, for example:

Project Recognizers ========================================= **Pipeline Jenkinsfile** Script Path: pipeline/workflow1.Jenkinsfile (or path to the file that contains valide Pipeline steps. ========================================= **Pipeline Jenkinsfile** Script Path: pipeline/workflow2.Jenkinsfile (or path to the file that contains valide Pipeline steps. ========================================= **Pipeline Jenkinsfile** Script Path: pipeline/workflow3.Jenkinsfile (or path to the file that contains valide Pipeline steps.

Another option here, could be Pipeline Shared Groovy Libraries Plugin, more details about this plugin can be found at Extending with Shared Libraries.

This approach gives you ability to use your custom scripts (Classes, steps, etc.) which means that you can define your own flow depending on repo name, project name, etc.


As of now, there should at least be the option to provide an alternative recognizer for the Jenkinsfile. This was added in JENKINS-34561 - Allow to detect different Jenkinsfile filenames. You can see the pull request at jenkinsci/workflow-multibranch-plugin/pull/59 which may help provide some background information in how the recognizers work.

In terms of multiple being recognized from a single source, JENKINS-35415 - Multiple branch projects per repository with different recognizers and JENKINS-43749 - Support multiple Jenkinsfiles from the same repository are requests that are very similar to this one.

A comment from Stephen Connolly in JENKINS-43749 says this about it:

What this is asking for is, instead, to create a computed folder with a pipeline job for each jenkinsfile within the branch.

I think the APIs should support that if somebody wants to take a stab at it. The only issue I see is that we may need to tweak the branch-api to allow for the branch jobs to be a non-job type (i.e. computed folder)

It sounds like you will need to implement a BranchProjectFactory (example: WorkflowBranchProjectFactory) that is a factory for a ComputedFolder (example: WorkflowMultiBranchProject).

Good luck!