I found the issue. I don’t know what the chances are that some-one will run into the same cause of this problem, but I’ll post the solution anyway.
At some point in the past git config insteadof
was set up for the user that runs the jenkins agent, see How to convert git:
urls to http:
urls. It was added to insert token authentication behind the scenes using
git config --global url."https://x-token-auth:sometoken@bitbucket.org".insteadOf https://bitbucket.org
The token that was used there was valid for some repos, but not for all.
Removing the config using git config --global -e
solved the issue. Thanks to @jim-redmond for his comment pointing me in the right direction.