Jenkins failing intermittently when pulling GitHub submodule

Viewed 94

I have a Jenkins (ver. 2.138.3) build job that pulls a big repo from an internally-hosted GitLab server, with most submodules being hosted on GitLab as well.

One recent addition is hosted on GitHub, for which permissions (via Deploy Keys) have been set up. This submodule fails to clone intermittently. Sometimes it works, sometimes it doesn't. The failure logs look like this:

08:34:28 hudson.plugins.git.GitException: Command "git submodule update <Folder>/<GitHubRepo>" returned status code 1:
08:34:28 stdout: 
08:34:28 stderr: Cloning into 'C:/workspace/<project>/.../<GitHubRepo>'...
08:34:28 ssh: connect to host ssh.github.com port 443: Connection timed out
08:34:28 fatal: Could not read from remote repository.
08:34:28 
08:34:28 Please make sure you have the correct access rights
08:34:28 and the repository exists.

I've changed the ~/.ssh/config to use port 443. The Jenkins' config parentCredentials is also set. I can't (easily) change the credentials on Jenkins, since they provide access to other dependencies for the project.

1 Answers

As commented, start by fixking/restricting the agent on which the job is run, to eliminate one variable.

Then connect to that agent and do a ssh -i /path/to/deploy/key git@github.com (copy, for testing, the deploy key on that agent), to check the SSH connection there.

Check if, on that agent (using the right account), you have a ~/.ssh/config file with

Host github.com
 Hostname ssh.github.com
 Port 443

Since it is using 443, (HTTPS), make sure git config credential.helper (on that agent) is not set, or it might have cached the wrong credentials (as seen at the bottom of this page).

Related