Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-54681

dir('path') is broken when used within "docker.image().inside{}"

      It seems that when 'dir' is used within a docker container, it is expected that the directory exists on the host and not within the docker container. The following minimal Jenkinsfile showcases this issue:

       

      node('docker') {
          stage('Build within docker') {
              // path to the workspace on the local machine and wthin the docker image
              workspace = env.WORKSPACE
              workspaceDocker = '/workspace'
      
              image = docker.image("ubuntu:18.04")
              image.pull()
      
              image.inside("-v ${workspace}:${workspaceDocker}") {
                  sh 'pwd'
      
                  sh """#!/bin/sh
                  cd ${workspaceDocker}
                  pwd
                  """
      
                  // this fails with the following error:
                  // java.nio.file.AccessDeniedException: /workspace
                  dir(workspaceDocker) {
                      sh 'pwd'
                  }
              }
          }
      }
      

       

       

          [JENKINS-54681] dir('path') is broken when used within "docker.image().inside{}"

          The issue seems to be actually stemming from the durable task plugin, which tries to create the workspace folder (in this case the 'dir' parameter) on the host file system, which fails: https://github.com/jenkinsci/durable-task-plugin/blob/master/src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java#L171-L175

          Krassimir Valev added a comment - The issue seems to be actually stemming from the durable task plugin, which tries to create the workspace folder (in this case the 'dir' parameter) on the host file system, which fails: https://github.com/jenkinsci/durable-task-plugin/blob/master/src/main/java/org/jenkinsci/plugins/durabletask/FileMonitoringTask.java#L171-L175

            Unassigned Unassigned
            kvalev Krassimir Valev
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: