I am working on a Jenkins multibranch pipeline project that builds code on multiple platforms. Our code uses the GitSCM plugin to checkout. There is one initial shallow checkout that just fetches some bootstrap scripts:
checkout scm: [
$class: 'GitSCM',
extensions: [
[$class: 'CloneOption', depth: 1, noTags: false, reference: '', shallow: true],
...
],
...
]
After this initial checkout, there is one extra full (i.e. deep) checkout for each platform that we build on.
The problem I am seeing is that Jenkins computes only one changelog that contains only the most recent commit on the branch. This makes sense for the initial shallow checkout as commit history is not fetched. However, I am not seeing additional changelogs for the other checkouts. I wouldn't mind the commit in the branch tip to get duplicated in additional changelogs.
Here's what I've tried so far to fix the problem:
- I tried disabling the changelog computation for the initial checkout by passing
changelog: false
in addition to thescm
parameter. However, this stopped changelogs being generated altogether, even for the other checkouts (I even tried explicitly settingchangelog: true
for the per-platform checkouts without success). - I tried adding the
ExcludeFromChangeSet
extension to the initial checkout. This extension is mentioned (but not fully documented) here (see under$class GitSCM >> extensions
): https://www.jenkins.io/doc/pipeline/steps/workflow-scm-step/. This failed becauseno known implementation of class hudson.plugins.git.extensions.GitSCMExtension is named ExcludeFromChangeSet
. - I had the idea that doing a deep but blobless clone (using Git's
--filter=blob:none
) might be a good compromise, but I cannot seem to find a way to specify that option. I'm also not sure whether this would actually fix the problem.
I'd rather not have to revert to a full checkout for the initial fetch. Interestingly, if there are any additional commits to the branch between the initial checkout and one of the per-platform checkouts, then an additional changelog for those new commits is generated.
Any help would really be appreciated here!
EDIT: Forgot to say that I also considered running the fetch command manually instead of using the checkout step, but I'd rather avoid that because GitSCM is currently doing all the heavy lifting for us (e.g. credentials management and cross-platform portability).