Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
477 views
in Technique[技术] by (71.8m points)

docker - 当使用Jenkins在Docker中运行Gradle构建时,无法将CD下载到目录(Cannot cd to directory when running a Gradle build in Docker with Jenkins)

I want to build a Gradle based project in a Jenkins pipeline.

(我想在詹金斯管道中建立一个基于Gradle的项目。)

The build step shall run in a Docker container.

(构建步骤应在Docker容器中运行。)

This is my current pipeline:

(这是我当前的管道:)

pipeline {
    agent any

    environment {
        GRADLE_DOCKER_IMAGE = 'gradle:5.6.4-jdk8'
        GRADLE_DOCKER_ARGS  = '-v ${HOME}/.m2:/maven/.m2'
    }

    stages {
        stage('Compile') {
            steps {
                script{
                    docker.image(GRADLE_DOCKER_IMAGE).inside("${GRADLE_DOCKER_ARGS}") {
                        sh './gradlew clean build --scan -s'
                    }
                }
            }
        }
    }
}

The pipeline itself finishes successfully but there is the following message in the log:

(管道本身成功完成,但是日志中有以下消息:)

./gradlew: 23: cd: can't cd to "./

If I omit the ./ (using just sh 'gradlew ... ) then the build fails as the command gradlew cannot be found.

(如果我省略./ (仅使用sh 'gradlew ... ),则构建将失败,因为找不到gradlew命令。)

What am I missing here?

(我在这里想念什么?)

  ask by Robert Strauch translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...