获取Jenkinsfile错误 - 找不到命令

时间:2018-02-06 13:02:28

标签: jenkins jenkins-pipeline

这个Jenkins文件有什么问题?我是新手,但我不知道我做错了什么

pipeline {
    agent any
    stages {
    stage('Test') {
        steps {
           dir ('/var/lib/jenkins/workspace/pipleline_2') { 

            }
        }     
}
}
post {
    always {
        sh 'hello2.sh'
    }
    failure {
       mail(from: "heenashree2010@gmail.com", 
       to: "qshoretechnologies@gmail.com", 
       subject: "That build passed.",
       body: "Nothing to see here")
    }
}
}

我收到以下错误。 hello2.sh存在于我指定的目录中,但我无法执行它。我也试过sh('hello2.sh'),但它对我不起作用。我究竟做错了什么?

Started by user qshore
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in /var/lib/jenkins/workspace/pipleline_2
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Test)
[Pipeline] dir
Running in /var/lib/jenkins/workspace/pipleline_2
[Pipeline] {
[Pipeline] }
[Pipeline] // dir
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (Declarative: Post Actions)
[Pipeline] sh
[pipleline_2] Running shell script
+ hello2.sh
/var/lib/jenkins/workspace/pipleline_2@tmp/durable-dbcba8b2/script.sh: line 2: hello2.sh: command not found
[Pipeline] mail
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
ERROR: script returned exit code 127
Finished: FAILURE  

1 个答案:

答案 0 :(得分:1)

找不到名为hello2.sh的脚本。确保它包含在您要检出的仓库中。