<p>I have create a pipeline like below and please note that I have the script files namely- "backup_grafana.sh" and "gitPush.sh" in source code repository where the Jenkinsfile is present. But I am unable to execute the script because of the following error:-</p>

<pre><code>/home/jenkins/workspace/grafana-backup@tmp/durable-52495dad/script.sh: 
line 1: backup_grafana.sh: not found
</code></pre>

<p>Please note that I am running jenkins master on kubernetes in a pod. So copying scripts files as suggested by the error is not possible because the pod may be destroyed and recreated dynamically(in this case with a new pod, my scripts will no longer be available in the jenkins master)</p>

<pre><code>pipeline {
agent {
    node {
        label 'jenkins-slave-python2.7'
    }
}
stages {
    stage('Take the grafana backup') {
        steps {
            sh 'backup_grafana.sh'
        }
    }
    stage('Push to the grafana-backup submodule repository') {
        steps {
            sh 'gitPush.sh'
        }
    }
 }
}
</code></pre>

<p>Can you please suggest how can I run these scripts in Jenkinsfile? I would like to also mention that I want to run these scripts on a python slave that I have already created finely.</p>

<p>If the command 'sh backup_grafana.sh' fails to execute when it actually should have successfully executed, here are two possible solutions.</p>

<p>1) Maybe you need a dot slash in front of those executable commands to tell your shell where they are. if they are not in your <code>$PATH</code>, you need to tell your shell that they can be found in the current directory. here's the fixed Jenkinsfile with four non-whitespace characters added:</p>

<pre><code>pipeline {
  agent {
    node {
      label 'jenkins-slave-python2.7'
    }
  }
  stages {
    stage('Take the grafana backup') {
      steps {
        sh './backup_grafana.sh'
      }
    }
    stage('Push to the grafana-backup submodule repository') {
      steps {
        sh './gitPush.sh'
      }
    }
  }
}
</code></pre>

<p>2) Check whether you have declared your file as a bash or sh script by declaring one of the following as the first line in your script:</p>

<pre><code>#!/bin/bash 
</code></pre>

<p>or</p>

<pre><code>#!/bin/sh
</code></pre>
