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

dir() does not change directory when used insider docker.inside block

    XMLWordPrintable

Details

    Description

      If you use dir() inside a docker.inside block - it will not work as expected.

      Take the following script, which works as expected with dir():

      node("docker") {    
              deleteDir()
                  stage 'build blueocean'   
                    dir('blueocean') {
                      git url: 'https://github.com/jenkinsci/blueocean-plugin.git'
                      sh 'ls -lah'
                    }           
                                
                  
                  stage 'prepare acceptance test harness'              
                      dir("acceptance") {
                        git url: 'https://github.com/cloudbees/blueocean-acceptance-test.git', branch: 'master'        
                        sh 'ls -lah'
                      }
                  
      }
      

      The contents of ear dir are correct. However, tweaking it slightly:

      node("docker") {    
              deleteDir()
              docker.image('cloudbees/java-build-tools').inside {
                  stage 'build blueocean'   
                    dir('blueocean') {
                      git url: 'https://github.com/jenkinsci/blueocean-plugin.git'
                      sh 'ls -lah'
                    }           
                                
                  
                  stage 'prepare acceptance test harness'              
                      dir("acceptance") {
                        git url: 'https://github.com/cloudbees/blueocean-acceptance-test.git', branch: 'master'        
                        sh 'ls -lah'
                      }
                      
              }
      }
      

      And the listings show a level above the dir, even though each dir is created, ie:

      + ls -lah
      total 16K
      drwxrwxr-x  4 jenkins jenkins 4.0K Jun 10 05:24 .
      drwxr-xr-x  4 root    root    4.0K Jun 10 05:24 ..
      drwxrwxr-x 13 jenkins jenkins 4.0K Jun 10 05:24 blueocean
      drwxrwxr-x  3 jenkins jenkins 4.0K Jun 10 05:24 blueocean@tmp
      
      ..
      
      + ls -lah
      total 24K
      drwxrwxr-x  6 jenkins jenkins 4.0K Jun 10 05:24 .
      drwxr-xr-x  4 root    root    4.0K Jun 10 05:24 ..
      drwxrwxr-x  4 jenkins jenkins 4.0K Jun 10 05:24 acceptance
      drwxrwxr-x  3 jenkins jenkins 4.0K Jun 10 05:24 acceptance@tmp
      drwxrwxr-x 13 jenkins jenkins 4.0K Jun 10 05:24 blueocean
      drwxrwxr-x  2 jenkins jenkins 4.0K Jun 10 05:24 blueocean@tmp
      

      Just a little bit maddening as I thought I was going insane.
      dir outside of docker block works just fine, as expected.

      Attachments

        Issue Links

          Activity

            michaelneale Michael Neale created issue -
            michaelneale Michael Neale made changes -
            Field Original Value New Value
            Description If you use dir() inside a docker.inside block - it will not work as expected.

            Take the following script, which works as expected with dir():

            {noformat}
            node("docker") {
                    deleteDir()
                        stage 'build blueocean'
                          dir('blueocean') {
                            git url: 'https://github.com/jenkinsci/blueocean-plugin.git'
                            sh 'ls -lah'
                          }
                                      
                        
                        stage 'prepare acceptance test harness'
                            dir("acceptance") {
                              git url: 'https://github.com/cloudbees/blueocean-acceptance-test.git', branch: 'master'
                              sh 'ls -lah'
                            }
                        
            }
            {noformat}

            The contents of ear dir are correct. However, tweaking it slightly:

            {noformat}
            node("docker") {
                    deleteDir()
                    docker.image('cloudbees/java-build-tools').inside {
                        stage 'build blueocean'
                          dir('blueocean') {
                            git url: 'https://github.com/jenkinsci/blueocean-plugin.git'
                            sh 'ls -lah'
                          }
                                      
                        
                        stage 'prepare acceptance test harness'
                            dir("acceptance") {
                              git url: 'https://github.com/cloudbees/blueocean-acceptance-test.git', branch: 'master'
                              sh 'ls -lah'
                            }
                            
                    }
            }
            {noformat}

            And the listings show a level above the dir, even though each dir is created, ie:

            {noformat}
            + ls -lah
            total 16K
            drwxrwxr-x 4 jenkins jenkins 4.0K Jun 10 05:24 .
            drwxr-xr-x 4 root root 4.0K Jun 10 05:24 ..
            drwxrwxr-x 13 jenkins jenkins 4.0K Jun 10 05:24 blueocean
            drwxrwxr-x 3 jenkins jenkins 4.0K Jun 10 05:24 blueocean@tmp

            ..

            + ls -lah
            total 24K
            drwxrwxr-x 6 jenkins jenkins 4.0K Jun 10 05:24 .
            drwxr-xr-x 4 root root 4.0K Jun 10 05:24 ..
            drwxrwxr-x 4 jenkins jenkins 4.0K Jun 10 05:24 acceptance
            drwxrwxr-x 3 jenkins jenkins 4.0K Jun 10 05:24 acceptance@tmp
            drwxrwxr-x 13 jenkins jenkins 4.0K Jun 10 05:24 blueocean
            drwxrwxr-x 2 jenkins jenkins 4.0K Jun 10 05:24 blueocean@tmp
            {noformat}


            Just a little bit maddening as I thought I was going insane.
            If you use dir() inside a docker.inside block - it will not work as expected.

            Take the following script, which works as expected with dir():

            {noformat}
            node("docker") {
                    deleteDir()
                        stage 'build blueocean'
                          dir('blueocean') {
                            git url: 'https://github.com/jenkinsci/blueocean-plugin.git'
                            sh 'ls -lah'
                          }
                                      
                        
                        stage 'prepare acceptance test harness'
                            dir("acceptance") {
                              git url: 'https://github.com/cloudbees/blueocean-acceptance-test.git', branch: 'master'
                              sh 'ls -lah'
                            }
                        
            }
            {noformat}

            The contents of ear dir are correct. However, tweaking it slightly:

            {noformat}
            node("docker") {
                    deleteDir()
                    docker.image('cloudbees/java-build-tools').inside {
                        stage 'build blueocean'
                          dir('blueocean') {
                            git url: 'https://github.com/jenkinsci/blueocean-plugin.git'
                            sh 'ls -lah'
                          }
                                      
                        
                        stage 'prepare acceptance test harness'
                            dir("acceptance") {
                              git url: 'https://github.com/cloudbees/blueocean-acceptance-test.git', branch: 'master'
                              sh 'ls -lah'
                            }
                            
                    }
            }
            {noformat}

            And the listings show a level above the dir, even though each dir is created, ie:

            {noformat}
            + ls -lah
            total 16K
            drwxrwxr-x 4 jenkins jenkins 4.0K Jun 10 05:24 .
            drwxr-xr-x 4 root root 4.0K Jun 10 05:24 ..
            drwxrwxr-x 13 jenkins jenkins 4.0K Jun 10 05:24 blueocean
            drwxrwxr-x 3 jenkins jenkins 4.0K Jun 10 05:24 blueocean@tmp

            ..

            + ls -lah
            total 24K
            drwxrwxr-x 6 jenkins jenkins 4.0K Jun 10 05:24 .
            drwxr-xr-x 4 root root 4.0K Jun 10 05:24 ..
            drwxrwxr-x 4 jenkins jenkins 4.0K Jun 10 05:24 acceptance
            drwxrwxr-x 3 jenkins jenkins 4.0K Jun 10 05:24 acceptance@tmp
            drwxrwxr-x 13 jenkins jenkins 4.0K Jun 10 05:24 blueocean
            drwxrwxr-x 2 jenkins jenkins 4.0K Jun 10 05:24 blueocean@tmp
            {noformat}


            Just a little bit maddening as I thought I was going insane.
            dir outside of docker block works just fine, as expected.
            michaelneale Michael Neale made changes -
            Priority Major [ 3 ] Minor [ 4 ]
            ndeloof Nicolas De Loof made changes -
            Link This issue depends on JENKINS-33510 [ JENKINS-33510 ]
            ndeloof Nicolas De Loof made changes -
            Resolution Duplicate [ 3 ]
            Status Open [ 1 ] Closed [ 6 ]
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 171827 ] JNJira + In-Review [ 210127 ]

            People

              jglick Jesse Glick
              michaelneale Michael Neale
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: