Supporting multi-branch for custom SCM plugin

28 views
Skip to first unread message

Berend D.

unread,
May 28, 2024, 8:45:23 AMMay 28
to jenkin...@googlegroups.com
Hi,

I'm building a custom SCM, taking some inspiration from the git SCM plugin.

My plugin can now detect the branch names and revisions of a repository and this spawns the sub-jobs nicely.

However, it also spawns jobs for branches which do not have a Jenkinsfile.

From my understanding, if the SCMFile::content() function returns a FileNotFoundException, should this not prevent the creation of the branch job?

Instead, Jenkins reports that the light-weight fetch of Jenkinsfile failed for a specific branch, and instead it will now do a full checkout to get the Jenkinsfile. Which of course fails since those branches truly have no Jenkinsfile.

The branches that do have a Jenkinsfile seem to work as intended, so this is purely a problem with filtering out the branch heads which can not be built.

I saw that the git SCM uses 'traits' to stack filters - my code is not using traits - but I can not find where the check is done for the Jenkins file existence.

So how do I tell the multi-branch plugin to not build specific branches from within my custom SCM?

Cheers!

Jesse Glick

unread,
May 28, 2024, 10:22:26 AMMay 28
to jenkin...@googlegroups.com
On Tue, May 28, 2024 at 8:45 AM Berend D. <cyberw...@gmail.com> wrote:
From my understanding, if the SCMFile::content() function returns a FileNotFoundException, should this not prevent the creation of the branch job?

No, by that point the branch project has already been created and now Jenkins is trying to run a build.

For GitHub for example, https://github.com/jenkinsci/github-branch-source-plugin/blob/5b0c0cea18c351352f2d33ad2491d148bb38a447/src/main/java/org/jenkinsci/plugins/github_branch_source/GitHubSCMProbe.java#L162 is where branches without `Jenkinsfile` (or whatever criteria have been configured for the multibranch project) would be excluded.

Berend D.

unread,
May 29, 2024, 7:24:42 AMMay 29
to jenkin...@googlegroups.com
Thanks - that was the missing bit of magic.

--
You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr1fnWPo%2BUDv-vyebbz0phchj0N8w-%3DLrNpOfMKmDP%3DEYg%40mail.gmail.com.
Reply all
Reply to author
Forward
0 new messages