-
Bug
-
Resolution: Unresolved
-
Minor
-
None
-
MacOs: Sequoia 15.6.1
Docker: Desktop Version 4.47.0 (206054)
Jenkins: 2.530
Jenkins Branch API Plugin: 2.1255.v2f5fe203584a_
Pipeline: Multibranch: 821.vc3b_4ea_780798
Creating a fairly vanilla multibranch pipeline in the create job UI.
I exporting to an XML file using the jenkins-cli (get-job) so that i can parameterize it and reuse it for other repos.
The problem is that for some reason or another when I import it with the cli (create-job), parameterized, or exactly how i exported it, I get the following exception:
ERROR: Unexpected exception occurred while performing create-job command. java.lang.ClassCastException: class org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject cannot be cast to class jenkins.branch.BranchSource (org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject is in unnamed module of loader 'PluginClassLoader for workflow-multibranch' @434dddd9; jenkins.branch.BranchSource is in unnamed module of loader 'PluginClassLoader for branch-api' @34195323) at PluginClassLoader for branch-api//jenkins.branch.MultiBranchProject.getSCMSources(MultiBranchProject.java:506) at PluginClassLoader for branch-api//jenkins.branch.MultiBranchProject.init2(MultiBranchProject.java:264) at PluginClassLoader for branch-api//jenkins.branch.MultiBranchProject.onLoad(MultiBranchProject.java:184) at PluginClassLoader for workflow-multibranch//org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject.onLoad(WorkflowMultiBranchProject.java:84) at hudson.model.Items.load(Items.java:376) at hudson.model.ItemGroupMixIn$2.call(ItemGroupMixIn.java:299) at hudson.model.ItemGroupMixIn$2.call(ItemGroupMixIn.java:297) at hudson.model.Items.whileUpdatingByXml(Items.java:132) at hudson.model.ItemGroupMixIn.createProjectFromXML(ItemGroupMixIn.java:297) at jenkins.model.Jenkins.createProjectFromXML(Jenkins.java:4283) at hudson.cli.CreateJobCommand.run(CreateJobCommand.java:76) at hudson.cli.CLICommand.main(CLICommand.java:263) at hudson.cli.CLIAction$ServerSideImpl.run(CLIAction.java:341) at hudson.cli.CLIAction$2.lambda$opened$0(CLIAction.java:196) at java.base/java.lang.Thread.run(Unknown Source)
I am attaching the parameterized version here:
jenkins-multi-branch-pipeline.xml
The problem seems to be caused by the sources tag:
<sources class="jenkins.branch.MultiBranchProject$BranchSourceList" plugin="branch-api@2.1255.v2f5fe203584a_"> <data> <jenkins.branch.BranchSource> <source class="jenkins.plugins.git.GitSCMSource" plugin="git@5.7.0"> <id>${JOB_GIT_ID}</id> <remote>${JOB_GIT_URL}</remote> <credentialsId>${JOB_GIT_CREDS}</credentialsId> <traits> <jenkins.plugins.git.traits.BranchDiscoveryTrait/> </traits> </source> <strategy class="jenkins.branch.DefaultBranchPropertyStrategy"> <properties class="empty-list"/> </strategy> </jenkins.branch.BranchSource> </data> <owner class="org.jenkinsci.plugins.workflow.multibranch.WorkflowMultiBranchProject" reference="../.."/> </sources>
If I remove that section, I can create it with the CLI, but I lose the git source configuration which defeats the point somewhat.
Hope this could get resolved, this one issue stands between being able to fully automate a setup.