I\'ve been having a lot of trouble trying to get a Jenkinsfile to work. I\'ve been trying to run this test script:
#!/usr/bin/env groovy
node {
stage(\'
In order to fix this issue, in case that you can't delete the PATH global property from "Manage Jenkins -> Configure System", you should add the following step:
withEnv(['PATH+EXTRA=/usr/sbin:/usr/bin:/sbin:/bin'])
Like following: for Scripted Pipeline:
node {
stage ('STAGE NAME') {
withEnv(['PATH+EXTRA=/usr/sbin:/usr/bin:/sbin:/bin']) {
sh '//code block'
}
}
}
or for Declarative Pipeline:
pipeline {
agent {
label 'master'
}
stages {
stage ('STAGE NAME') {
steps {
withEnv(['PATH+EXTRA=/usr/sbin:/usr/bin:/sbin:/bin']) {
sh '''
//code block
'''
}
}
}
I hope this helps. I also struggled a lot to find a solution for this.