Jenkins Pipeline: Executing a shell script
If the command 'sh backup_grafana.sh' fails to execute when it actually should have successfully executed, here are two possible solutions.
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 $PATH
, 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:
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' } } }}
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:
#!/bin/bash
or
#!/bin/sh