在詹金斯上执行Maven命令时权限被拒绝

时间:2018-09-17 13:32:38

标签: jenkins-pipeline maven-3 ubuntu-16.04 permission-denied

我的Jenkinsfile中有以下管道:

pipeline {
    agent any
    stages {
        stage("Compile") {
            steps {
                sh "./mvnw clean package"
            }
        }
        stage("Unit test") {
            steps {
                sh "./mvnw test"
            }
        }
    }
} 

构建失败,日志如下:

...
        [Pipeline] }
        [Pipeline] // stage
        [Pipeline] withEnv
        [Pipeline] {
        [Pipeline] stage
        [Pipeline] { (Compile)
        [Pipeline] sh
        [calculator] Running shell script
        + ./mvnw clean package
        /var/lib/jenkins/workspace/calculator@tmp/durable-ed9b8653/script.sh: 2: /var/lib/jenkins/workspace/calculator@tmp/durable-ed9b8653/script.sh: ./mvnw: Permission denied
        [Pipeline] }
        [Pipeline] // stage
        [Pipeline] stage
        [Pipeline] { (Unit test)
        Stage "Unit test" skipped due to earlier failure(s)
        [Pipeline] }
        [Pipeline] // stage
        [Pipeline] }
        [Pipeline] // withEnv
        [Pipeline] }
        [Pipeline] // node
        [Pipeline] End of Pipeline
        ERROR: script returned exit code 126
        Finished: FAILURE

我已将mvnw的权限设置为777,但无法解决问题。 谁能告诉我解决方案?

0 个答案:

没有答案