This is an old thread I have a solution that worked for me so I thought I'd share. I am no Jenkins expert so I don't know if this is some kind of horrible hack, but basically the idea is to ignore the scm object provided by the multi-branch pipeline and setup your own.
I use this for a multi-project Java repository and so far it is working well. I created one Jenkins multi-branch pipeline for each of my Java sub-project and they all point to the same Jenkinsfile. This solution has 2 restrictions: - The Git URL must be in the Jenkinsfile. - The name of the Jenkins multi-branch pipeline project must be the same as the name of the sub-project directory. Example Jenkinsfile: // Git URL def projectGitURL = 'https://<myhost>/<mymultiproject-repo>' def projectGitCredsName = '' //applicationName is derived from Jenkins project name (which is second to last in the full name) def jobPathElements = currentBuild.fullProjectName.split('/') def applicationName = jobPathElements[jobPathElements.length >= 2? jobPathElements.length-2: jobPathElements.length-1] // Project's POM file def projectPom = applicationName + '/pom.xml' // Git Branch/Paths to check for changes def projectGitWatchedPathRegex = applicationName + '/.*' def projectGitWatchedBranches = [[name: '*/' + env.BRANCH_NAME]] def projectReleaseBranchRegex = 'master.*' ... pipeline { agent any; ... options { buildDiscarder logRotator(artifactNumToKeepStr: '5', numToKeepStr: '5') disableConcurrentBuilds() timestamps() skipDefaultCheckout() //skip SCM pull before first stage, we'll do our own } ... stages { stage('Checkout from SCM') { steps { //We won't be using the simple "checkout(scm)" here because we want //to setup our own path restriction and that is not supported //by the default multibranch git provider. //checkout(scm) checkout([$class: 'GitSCM', userRemoteConfigs: [[credentialsId: projectGitCredsName, url: projectGitURL]], branches: projectGitWatchedBranches, extensions: [[$class: 'PathRestriction', //SCM poll filter by path excludedRegions: '', includedRegions: projectGitWatchedPathRegex], [$class: 'LocalBranch', localBranch: '**']]]) } } ... stage('Build and Deploy') { steps { withMaven(maven: 'maven') { sh(script: "mvn --batch-mode --errors --update-snapshots -Dbuild_number=${BUILD_NUMBER} -f ${applicationName} clean deploy") } } } ... } } -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/631f22fa-5dd6-46ca-b3f2-ecb643e74bba%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.