When using the Multibranch Pipeline and Jenkinsfile, and with a Global Shared Library configuration, the initial build of a new branch of a multi-branch pipeline fails with the message: "fatal: bad object XXXXX". Doing the build manually or pushing a new change to trigger the build, and everything works without issue.
As far as I can tell, the issue is that we are using Global Shared Libraries that are set to load automatically as well as the Remote Jenkinsfile plugin to manage the build. The logs show that the process the job uses is:
- Checkout using the normal Git Plugin the repo with the Jenkinsfile to use for the job. The relevant lines are:
Checking out Revision 80c4c1bcf8a763c1edb16e1fb32f921008b87e1b (origin/main)10:10:06 > git config core.sparsecheckout # timeout=10*10:10:06* > git checkout -f 80c4c1bcf8a763c1edb16e1fb32f921008b87e1b # timeout=10
- Checkout the Global Shared Library repo using the Git Plugin for the shared libraries to load. The relevant lines are:
Checking out Revision 092d776fba95a9818c68c80f40b1afcc6273f553 (main)10:10:08 > git config core.sparsecheckout # timeout=10*10:10:08* > git checkout -f 092d776fba95a9818c68c80f40b1afcc6273f553 # timeout=10
- Right after this checkout, the message: fatal: bad object 80c4c1bcf8a763c1edb16e1fb32f921008b87e1b is shown. Note that the the refspec is the one for the Remote Jenkinsfile that was used.
We have tried turning off the implicit loading of the Shared Libraries, and we get the same issue when the main codeline is checked out, using the Bitbucket plugin instead of the main git plugin. So it would seem that the issue is somehow related to using the "Remote Jenkinsfile" plugin to read the Jenkinsfile, though it is not clear why.