<p>I'm running Jenkins on Kubernetes with the git plugin installed. 
Now I want to use git commands in my script, which fails with the log: </p>

<pre><code>script.sh: line 1: git: not found
</code></pre>

<p>My script:  </p>

<pre><code>stage('Package Helm Chart'){
            sh """ 
              #!/bin/bash

              echo "Pushing to remote Repository.."

              git checkout master

              git add &lt;myfilehere&gt;

              git commit -m "[Jenkins] Adding Artifact ${env.BUILD_NUMBER} to repository"

              git push

              echo "Successfully pushed artifact to repository"
            """
</code></pre>

<p>Any idea on how to fix this? </p>

<p>Cheers 
Jst </p>

<p>The sh command in question should run on a jenkins node inside a node block. This command will then run in a shell on that node. To use git in the sh tag of a pipeline script you need to have git installed and on the PATH on the node that you want to use.</p>

<p>If you are using Kubernetes, then I assume you are running the Jenkins master or the node from a docker image, thus this image will need git installed and on the PATH.</p>

<p>Once this is done the shell will be able to find git.</p>
