| Even though I understand the current flags are a bit confusing, the approach of using sh might not work for the specific use case. Let me explain it though. A multibranch pipeline project, which its triggers on PR basis, does trigger a Downstream pipeline, which does checkout the repo with something like the below code:
def extensions = []
extensions.add([$class: 'CloneOption', depth: 5, noTags: false, reference: "${reference != null ? reference : '' }", shallow: true])
extensions.add([$class: 'PreBuildMerge', options: [mergeTarget: "${mergeTarget}", mergeRemote: "${mergeRemote}"]])
checkout([$class: 'GitSCM', branches: [[name: "${branch}"]],
doGenerateSubmoduleConfigurations: false,
extensions: extensions,
submoduleCfg: [],
userRemoteConfigs: [[
refspec: '+refs/heads/*:refs/remotes/origin/* +refs/pull/*/head:refs/remotes/origin/pr/*',
credentialsId: "${credentialsId}",
url: "${repo}"]]])
The idea is, to use the PR commit and do a merge with the mergeTarget branch. In some cases, normally when the PR got obsoleted then the above snippet causes:
Branch not suitable for integration as it does not merge cleanly: Command "git merge --ff 2e9655537626c4c340770ada2ea7d36bd5632132" returned status code 128
...
fatal: refusing to merge unrelated histories
That's the reason I'd like to add that particular flag. Or maybe I've misunderstood how to solve that particular use case. Cheers |