Job DSL for multi-branch jobs from Perforce

Hi, Jenkins community,

We are trying to translate our job creation into more DSL-driven. However, when I was trying to translate the multi-branch job which is scmed in perforce. I got the following error. Can you please provide me with some idea on what I did wrong?:

        Processing provided DSL script
        ERROR: java.io.IOException: Failed to persist config.xml
        Finished: FAILURE

Here is my DSL script:

jobs:
  - script: >
      folder('test');
      multibranchPipelineJob('my-build') {
        factory {
            workflowBranchProjectFactory {
                scriptPath('Build/Jenkinsfile/ManualTask.Jenkinsfile')
            }
        }
        branchSources {
          branchSource {
            source {
              configure { node ->
                def p4source = node / 'source'
                p4source / '@class'('org.jenkinsci.plugins.p4.scm.BranchesScmSource')
                p4source / 'credential'('P4_Credential')
                p4source / 'includes'('//some/path')
                p4source / 'charset'('none')
                p4source / 'format'('jenkins-${NODE_NAME}-${JOB_NAME}-${EXECUTOR_NUMBER}')
                
                // Now, we define the populate strategy
                def populate = p4source / 'populate'
                populate / '@class'('org.jenkinsci.plugins.p4.populate.CheckOnlyImpl')
                populate / 'have'(false)
                populate / 'force'(false)
                populate / 'modtime'(false)
                populate / 'quiet'(true)
              }
            }
          }
        }
        orphanedItemStrategy {
          discardOldItems {
              daysToKeep(-1)
              numToKeep(-1)
          }
        }
        triggers {
            periodicFolderTrigger{
              interval('H/5 * * * *')
            }
        }
      }