Jenkins docker build customWorkspace doesn't work

Viewed 403

Why doesn't the customWorkspace doesn't work for a new directory for example /tmp/checkout-directory?

If I choose /var/jenkins_home/workspace/44. pipeline-agent-dockerfile-customWorkspace/checkout-directory then it works.

pipeline {
    agent none
    stages {
        stage('Checkout') {
            agent any
            steps {
                checkout([$class: 'GitSCM',
                        branches: [[name: "origin/master"]],
                        userRemoteConfigs: [[
                            url: 'https://github.com/test/pipeline-agent-dockerfile.git' ]],
                        extensions: [[$class: 'RelativeTargetDirectory', relativeTargetDir: 'checkout-directory']]
                    ])
            }
        }
        stage('dockerfile') {
            agent {
                dockerfile {
                    customWorkspace '/tmp/checkout-directory'       
                }
            }
            steps {
                sh 'cat /etc/lsb-release'
            }
        }
    }
}

Error:

Started by user admin
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] stage
[Pipeline] { (Checkout)
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/44. pipeline-agent-dockerfile-customWorkspace
[Pipeline] {
[Pipeline] checkout
The recommended git tool is: NONE
No credentials specified
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
 > git config remote.origin.url https://github.com/test/pipeline-agent-dockerfile.git # timeout=10
Fetching upstream changes from https://github.com/test/pipeline-agent-dockerfile.git
 > git --version # timeout=10
 > git --version # 'git version 2.20.1'
 > git fetch --tags --force --progress -- https://github.com/test/pipeline-agent-dockerfile.git +refs/heads/*:refs/remotes/origin/* # timeout=10
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
Checking out Revision 49b4a985b835c6bc63ed4d0a548c733c516444a0 (refs/remotes/origin/master)
 > git config core.sparsecheckout # timeout=10
 > git checkout -f 49b4a985b835c6bc63ed4d0a548c733c516444a0 # timeout=10
Commit message: "Dockerfile"
 > git rev-list --no-walk 49b4a985b835c6bc63ed4d0a548c733c516444a0 # timeout=10
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] stage
[Pipeline] { (dockerfile)
[Pipeline] node
Running on Jenkins in /var/jenkins_home/workspace/44. pipeline-agent-dockerfile-customWorkspace
[Pipeline] {
[Pipeline] ws
Running in /tmp/checkout-directory
[Pipeline] {
[Pipeline] isUnix
[Pipeline] readFile
[Pipeline] }
[Pipeline] // ws
[Pipeline] }
[Pipeline] // node
[Pipeline] }
[Pipeline] // stage
[Pipeline] End of Pipeline
java.nio.file.NoSuchFileException: /tmp/checkout-directory/Dockerfile
    at sun.nio.fs.UnixException.translateToIOException(UnixException.java:86)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:102)
    at sun.nio.fs.UnixException.rethrowAsIOException(UnixException.java:107)
    at sun.nio.fs.UnixFileSystemProvider.newByteChannel(UnixFileSystemProvider.java:214)
    at java.nio.file.Files.newByteChannel(Files.java:361)
    at java.nio.file.Files.newByteChannel(Files.java:407)
    at java.nio.file.spi.FileSystemProvider.newInputStream(FileSystemProvider.java:384)
    at java.nio.file.Files.newInputStream(Files.java:152)
    at hudson.FilePath.newInputStreamDenyingSymlinkAsNeeded(FilePath.java:2113)
    at hudson.FilePath.read(FilePath.java:2098)
    at hudson.FilePath.read(FilePath.java:2090)
    at org.jenkinsci.plugins.workflow.steps.ReadFileStep$Execution.run(ReadFileStep.java:104)
    at org.jenkinsci.plugins.workflow.steps.ReadFileStep$Execution.run(ReadFileStep.java:94)
    at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution.lambda$start$0(SynchronousNonBlockingStepExecution.java:47)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE
1 Answers
Related