Jenkins org.jenkinsci.plugins.gitclient.Git directly on the pipeline?

Jenkins setup: On premise Version 2.516.2

Hey all,

The question may sound weird, but we have a somewhat convoluted set up using Docker and Git with submodules.

One of the issues we have is that we need to change the URLs in .gitmodules before doing anything submodule related, and calling git submodule update --init doesn’t work properly ‘cause the Jenkins user is on AD and SSH fails to identify the username while running any Git operations.

But, weird thing, checkout works fine.

So I’m thinking about using org.jenkinsci.plugins.gitclient.Git directly to initialize the submodules after changing .gitmodules. But I can’t find any explanation on how to do so (or even if it is possible, although “no information” is a good indication).

Does anyone have any idea on how to call gitclient on a declarative pipeline?

Have you tried setting up the git config insteadOf directive at user level before calling the submodule?

See Git - git-config Documentation and an example at git global url insteadOf setup · GitHub

I’m using this to force all URLs to SSH on my laptop but only on certain projects.