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

archiveArtifacts and fileExists inconsistent in docker.inside() closure

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • docker-workflow-plugin
    • None
    • Jenkins 2.112
      Docker Pipeline 1.15, 1.17

      The following Pipeline code produces an error:

      def image = docker.image("any_existing_image_eg_alpine")
      image.inside {
          sh 'date > /tmp/test.txt'
          sh 'cat /tmp/test.txt' //works, shows file
      
          def fileContents = readFile '/tmp/test.txt' //works
          echo "Contents: ${fileContents}" //works, shows file
      
          echo "Exists: ${fileExists('/tmp/test.txt')}" //FAILS (returns false)
          archiveArtifacts '/tmp/*.txt' //FAILS the build
      }
      

      archiveArtifacts always reports that it matched no files (except in $WORKSPACE, see below).

      DSL steps in docker summary (what I've tried):

      • readFile(): works correctly on files in or out of $WORKSPACE
      • writeFile(): works correctly on files in or out of $WORKSPACE
      • fileExists(): works correctly only on files in $WORKSPACE (auto-mounted volume)
      • archiveArtifacts(): archives only files in $WORKSPACE  (auto-mounted volume) 

      So I guess there is a pattern ... and yet the behavior is inconsistent.  I could not find any documentation that explains what the rules are.

      UPDATE: readFile() now throws NoSuchFileException (docker-pipeline 1.17 and pipeline-basic-steps 2.7) for files outside the workspace, which is probably better.

       

       

            Unassigned Unassigned
            akom Alexander Komarov
            Votes:
            3 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated: