1

I have been running into an issue where most, but not all, of the jenkins jobs to build our branches are failing, when connecting by proxy, with:

 > git fetch --tags --progress https://github.com/myorg/myrepo.git 
 > +refs/heads/*:refs/remotes/origin/* # timeout=60
 > ERROR: Error cloning remote repo 'origin'
 > hudson.plugins.git.GitException: Command "git fetch --tags --progress      >      
 > https://github.com/myorg/myrepo.git +refs/heads/*:refs/remotes/origin/*"      >      
 > returned status code 128:
 > stdout: 
 > stderr: error: RPC failed; result=18, HTTP code = 200
 > fatal: The remote end hung up unexpectedly

The Jenkins script that I have, started like so:

stage ( "Checkout" ) {
      sh label: "Use proxy to access GitHub", script:
      """
        git config --global http.proxy ${httpProxy}
      """
      scmVars = checkout scm 
      ... ^^ this call wraps the failing `git fetch --tags --progress` call

Reading various other stack articles (git bash: error: RPC failed; result = 18, HTP code = 200B | 1KiB/s Git clone return result=18 code=200 on a specific repository etc), the only thing I have found of note is to increase the postBuffer size. ie. git config --global http.postBuffer 524288000 # 500mb

This then looks like:

  stage ( "Checkout" ) {
      sh label: "Use proxy to access GitHub", script:
      """
        git config --global http.postBuffer 524288000
        git config --global http.proxy ${httpProxy}

      """
      scmVars = checkout scm
      ...

This has no net effect. ~90%+ of the builds fail on fetch; ~10% will go through (independent of the branch being built).

This is where affairs become very hard to explain: after hours of banging my head against the wall, I eventually decided to invoke checkout scm twice, consecutively; first I call scm checkout in a try/catch. The second call, I assign scmVars. (nb. if the first call succeeds, the second is idempotent). This looks like:

  stage ( "Checkout" ) {
      sh label: "Use proxy to access GitHub", script:
      """
        git config --global http.postBuffer 524288000
        git config --global http.proxy ${httpProxy}

      """

      try { 
        checkout scm
      } catch (nil) {
        println "Initial SCM CHECKOUT fails"
      }
      
      scmVars = checkout scm

Calling checkout scm twice, catching an error on the first call, succeeds every time, in over 50 runs.

Why?

  • Is git config --global http.postBuffer 524288000 being applied to both calls or only the second?
  • If http.postBuffer is only set on the second call, how do I correctly set the property for the first call?
  • In broad strokes, what is actually happening here?

long-time listener, first-time caller; I am not a dev-ops engineer, I just play one on T.V. - thank you in advance for any and all insights

0 Answers0