title: Jenkins pipeline - sh - git push fails randomly - ERROR: script returned exit code 128
body: <p>Environment:<br />
  ENV Jenkins Operator<br />
  Jenkins 2.249.1<br />
  Pipeline</p>
  <p><strong>FAILURE</strong> </p>
  <pre><code> [master cc6be50] New customer test60     
  1 file changed, 32 insertions     
  create mode 100644 deployment/test60.yaml
   + git push origin
  [Pipeline] }
  [Pipeline] // stage[Pipeline] }
  [Pipeline] // withEnv[Pipeline] }
  [Pipeline] // withCredentials[Pipeline] }
  [Pipeline] // node[Pipeline] }
  [Pipeline] // podTemplate
  [Pipeline] End of Pipeline
  ERROR: script returned exit code 128     
  Finished: FAILURE
  </code></pre>
  <p> <strong>SAME CODE SUCCESSFUL RUN:</strong></p>
  <pre><code>+ git commit -m New customer test49
   [master 9c0b093] New customer test49
   1 file changed, 32 insertions
   create mode 100644 deployment/test49.yaml     
  + git push origin
   To https://github.com/****/xxxxxxxxx.git 770e517..9c0b093 master -&gt; master
  </code></pre>
  <p>PLEASE HELP THIS HAS BEEN GOING ON FOR SOMETIME NOW, I AM NOT ABLE TO FIGURE OUT WHAT IS THE ISSUE.</p>
  <ol>
  <li>I am storing credentials from Jenkins to checkout code.</li>
  <li>Using sh within stage ''' multi commands 
  '''
   3. This used to work in  older version of Jenkins, recently jenkins operator got restarted and pulled recent version of Jenkins 2.249.1</li>
  <li>I am mostly seeing the issue with &quot;git push&quot; or in &quot;git&quot; related cmds</li>
  </ol>
  <p>FAILURE ON &quot;git ls-remote&quot;. </p>
  <pre><code>+ git ls-remote --heads origin test47     [Pipeline] }[Pipeline] // stage
  [Pipeline] }
  [Pipeline] // withEnv[Pipeline] }
  [Pipeline] // withCredentials[Pipeline] }
  [Pipeline] // node[Pipeline] }
  [Pipeline] // podTemplate
  [Pipeline] End of Pipeline
  ERROR: script returned exit code 128
   Finished: FAILURE
  </code></pre>
  <p> My earlier working code was based on create new branch and pushing to repo which has random failures so changed the logic to directly push to master.</p>
  <pre><code>Another failure while deleting the remote branch
  
  Branch name test58 already exists, deleting it
  + git push -d origin test58
  [Pipeline] }[Pipeline] // stage[Pipeline] }
  [Pipeline] // withEnv[Pipeline] }
  [Pipeline] // withCredentials[Pipeline] }
  [Pipeline] // withEnv[Pipeline] }
  [Pipeline] // node[Pipeline] }
  [Pipeline] // podTemplate[Pipeline]
  End of Pipeline
  ERROR: script returned exit code 128
  Finished: FAILURE
  </code></pre>
  <p>CMD FAILED</p>
  <pre><code>+ git ls-remote --heads origin test81
  [Pipeline] }
  [Pipeline] // stage
  [Pipeline] }
  [Pipeline] // withEnv
  [Pipeline] }
  [Pipeline] // withCredentials
  [Pipeline] }
  [Pipeline] // node
  [Pipeline] }
  [Pipeline] // podTemplate
  [Pipeline] End of Pipeline
  ERROR: script returned exit code 128
  Finished: FAILURE
  </code></pre>
  <p>SAME CMD SUCCESS</p>
  <pre><code>wc=$(git ls-remote --heads origin $BR |wc |awk '{print$1}')
  + git ls-remote --heads origin test81 
  75dfaff2153dec5730066e716c37ad67a46d733a refs/heads/test81 
  + git ls-remote --heads origin test81 
  + wc + awk {print$1} 
  + wc=1 
  + echo Value of wc is $wc Value of wc is $wc 
  + [ 1 -ne 0 ] 
  + echo Branch name test81 already exists, deleting it Branch name test81 already exists, deleting it 
  + git config push.default simple 
  + git push -d origin test81 
  To https://github.com/****/svc_workflowexecutor.git 
  - [deleted] test81
  </code></pre>
  <p>RANDOM FAILURES.</p>
  <p>The issues happens randomly in different places (there are about 10 different repos I push to), we are also seeing API rate limit exceeded issue.</p>
  <p>Still the issue not resolved, will keep you updated.</p>