jenkinsjenkins-declarative-pipelinejenkins-git-plugin

Cloning from GitHub using Git Plugin with Declarative Jenkins Pipeline


I've been having problems cloning from GitHub in my declarative pipeline. I've tried this:

git branch: 'refs/tags/5.9.0',
    credentialsId: '<some credentials>',
    url: "https://github.com/ARM-software"

which gives this error:

The recommended git tool is: NONE
No credentials specified
 > git rev-parse --resolve-git-dir /var/lib/jenkins/jobs/project/workspace/CMSIS_5/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/ARM-software # timeout=10
Fetching upstream changes from https://github.com/ARM-software
 > git --version # timeout=10
 > git --version # 'git version 2.34.1'
Setting http proxy: git-mirror-uk.ctuk.lan:8080
 > git fetch --tags --force --progress -- https://github.com/ARM-software +refs/heads/*:refs/remotes/origin/* # timeout=10
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.com/ARM-software
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:999)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1241)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1305)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:136)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:101)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:88)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --force --progress -- https://github.com/ARM-software +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: fatal: unable to access 'https://github.com/ARM-software/': gnutls_handshake() failed: An unexpected TLS packet was received.

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2846)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2185)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:635)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:997)
    ... 11 more
ERROR: Error fetching remote repo 'origin'
ERROR: Maximum checkout retry attempts reached, aborting

and

checkout([
$class: 'GitSCM',
    extensions: [[
        $class: 'CloneOption',
        shallow: true,
        depth:   1,
        timeout: 30]],
    userRemoteConfigs: [[
        url:           'https://github.com/ARM-software/CMSIS_5.git',
        credentialsId: 'some credentials']]

which results in

The recommended git tool is: NONE
using credential credentials
 > git rev-parse --resolve-git-dir /var/lib/jenkins/jobs/project/workspace/CMSIS_5/.git # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/ARM-software/CMSIS_5.git # timeout=10
Using shallow fetch with depth 1
Fetching upstream changes from https://github.com/ARM-software/CMSIS_5.git
 > git --version # timeout=10
 > git --version # 'git version 2.34.1'
using GIT_SSH to set credentials Uk Jenkins Credentials
Verifying host key using known hosts file, will automatically accept unseen keys
Setting http proxy: git-mirror-uk.ctuk.lan:8080
 > git fetch --tags --force --progress --depth=1 -- https://github.com/ARM-software/CMSIS_5.git +refs/heads/*:refs/remotes/origin/* # timeout=30
ERROR: Error fetching remote repo 'origin'
hudson.plugins.git.GitException: Failed to fetch from https://github.com/ARM-software/CMSIS_5.git
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:999)
    at hudson.plugins.git.GitSCM.retrieveChanges(GitSCM.java:1241)
    at hudson.plugins.git.GitSCM.checkout(GitSCM.java:1305)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep.checkout(SCMStep.java:136)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:101)
    at org.jenkinsci.plugins.workflow.steps.scm.SCMStep$StepExecutionImpl.run(SCMStep.java:88)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
    at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
    at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
    at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
    at java.base/java.lang.Thread.run(Thread.java:840)
Caused by: hudson.plugins.git.GitException: Command "git fetch --tags --force --progress --depth=1 -- https://github.com/ARM-software/CMSIS_5.git +refs/heads/*:refs/remotes/origin/*" returned status code 128:
stdout: 
stderr: fatal: unable to access 'https://github.com/ARM-software/CMSIS_5.git/': gnutls_handshake() failed: An unexpected TLS packet was received.

    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandIn(CliGitAPIImpl.java:2846)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl.launchCommandWithCredentials(CliGitAPIImpl.java:2185)
    at org.jenkinsci.plugins.gitclient.CliGitAPIImpl$1.execute(CliGitAPIImpl.java:635)
    at hudson.plugins.git.GitSCM.fetchFrom(GitSCM.java:997)
    ... 11 more
ERROR: Error fetching remote repo 'origin'
ERROR: Maximum checkout retry attempts reached, aborting

I've tried with no credentials, different branches etc.

I can do a git clone locally on the slave, and

sh 'rm -rf CMSIS_5 && git clone --depth 1 --branch 5.9.0 https://github.com/ARM-software/CMSIS_5.git'

works fine within my Jenkinsfile.

Is there something I'm missing?

Thanks!


Solution

  • Look at this log entry:

    Setting http proxy: git-mirror-uk.ctuk.lan:8080
    

    Looks like you set up a proxy before accessing github.com. Your sh command doesn't do that and clones successfully. I would find what makes Jenkins git plugin use a proxy and if that proxy is working as expected (for https - I doubt it).