Hi, i have a Jenkinsfile in my repository. On Jenkins i setted up a Multibranch Pipeline Project for the repository. Everything is fine, it builds via Jenkinsfile for everey branch i create and triggers also on push etc. Now i want to also build at pull requests. So the pull request is triggering the build. The Problem is now that my checkout is not working for the pull request. So now i have the problem that the branch name is "PR-[number]" when i create a pull request. So checking out that branch is not possible, because it not exists. I also tried it with But then nothing builds. The git server is a local Bitbucket server. What can i do to get also pullrequests Building? Regards Kai |
pipeline{
agent {label 'master'} triggers { pollSCM('H 0 1 1 0') } options{
buildDiscarder(logRotator(numToKeepStr: '3'))
timeout(time: 1, unit: 'HOURS')
skipDefaultCheckout()
retry(3)
} environment{
INSTALL_DIR='my/install/dir'
} stages{
stage('Checkout'){
steps{
script{
try{
cleanWs notFailBuild: true
checkout(
[
$class: 'GitSCM',
branches: [[name: '${BRANCH_NAME}']],
doGenerateSubmoduleConfigurations: false,
extensions:
[
[
$class: 'CloneOption',
depth: 0,
noTags: false,
reference: '',
shallow: true
],
[
$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: false,
recursiveSubmodules: true,
reference: '',
trackingSubmodules: false
],
[
$class: 'CleanBeforeCheckout'
]
],
submoduleCfg: [],
userRemoteConfigs:
[
[
credentialsId: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
url: 'my.git'
]
]
]
)
}catch(e){
String error = e.toString()
echo error
currentBuild.result = 'Failure'
emailext body: '${DEFAULT_CONTENT}', subject: '${DEFAULT_SUBJECT}', recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'UpstreamComitterRecipientProvider']]
throw e
}
finally{
cleanWs notFailBuild: true
}
}
}
}
}
}