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

Declarative pipeline with Docker image not running steps inside container on Windows

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Minor Minor
    • docker-workflow-plugin
    • None
    • Windows Server 2019 (1809) agent node running Docker 19.03.4, Docker Pipeline 1.21

      I'm running a very simple test with a Nano Server container, now that the Docker Pipeline plugin has Windows support, but the steps in my stage appear to be running on the agent node instead. The pipeline looks like this:

      pipeline {
        agent {
          docker { 
            image 'mcr.microsoft.com/windows/nanoserver:1809' 
          }
        }
        stages {
          stage('Test') {
            steps {
              bat 'echo I am a temporary file >> temp.txt'
              bat 'type temp.txt'
            }
          }
        }
      }
      

      However, the temp.txt file I append to is getting longer and longer (as it's appended to with each build, and nothing deletes it), and indeed I can see it sitting in the filesystem on my agent node that runs Docker. For example, the console log shows this for my 4th build:

      00:00:04.251  C:\Jenkins\workspace\Sandbox\DockerTest>echo I am a temporary file  1>>temp.txt 
      00:00:04.259  [Pipeline] bat
      00:00:04.563  
      00:00:04.563  C:\Jenkins\workspace\Sandbox\DockerTest>type temp.txt 
      00:00:04.563  I am a temporary file 
      00:00:04.563  I am a temporary file 
      00:00:04.563  I am a temporary file 
      00:00:04.563  I am a temporary file 
      

      Am I missing something fundamental about how this is supposed to work? I had expected this syntax would result in the echo and type commands being run in a container that was then discarded, resulting in an entirely new temp.txt file each time, and nothing left over.

            Unassigned Unassigned
            medianick Nick Jones
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: