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

Powershell plugin inside container hangs

    Details

    • Similar Issues:

      Description

      The powershell plugin when used within docker container enters a hang state. I would expect it to fail if powershell core is not installed, which works if the same thing is ran outside docker. The jenkins agent is a Ubuntu 16.04 machine.

      I dont see any other process also running within the docker container in the hung state except cat

      //

      CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
      xxxx alpine:latest "cat" 5 minutes ago Up 5 minutes ecstatic_galileo
      PS /home/administrator> docker top 2a2a21fe5dbc
      WARNING: Error loading config file: /home/administrator/.docker/config.json: open /home/administrator/.docker/config.json: permission denied
      UID PID PPID C STIME TTY TIME CMD
      adminis+ 5372 5350 0 07:39 pts/0 00:00:00 cat

      //Sample Jenkinsfile

      timestamps {

      //linux docker
      node("LinuxDocker") {

      //Works
      docker.image("alpine:latest").inside

      { sh("echo command inside docker") }

      // Hangs

      docker.image("alpine:latest").inside

      { powershell(script:"echo command inside docker") }

      }

      }

      Hung output
      ==================================================
      [Pipeline]

      { [Pipeline] sh 20:39:30 + echo command inside docker 20:39:30 command inside docker [Pipeline] }

      $ docker top <xxxxguid> -eo pid,comm
      WARNING: Error loading config file: /home/administrator/.docker/config.json: open /home/administrator/.docker/config.json: permission denied
      $ docker stop --time=1 <xxxxguid>
      $ docker rm -f <xxxxguid>
      [Pipeline] // withDockerContainer
      [Pipeline] sh
      20:39:32 + docker inspect -f . alpine:latest
      20:39:32 WARNING: Error loading config file: /home/administrator/.docker/config.json: open /home/administrator/.docker/config.json: permission denied
      20:39:32 .
      [Pipeline] withDockerContainer
      20:39:32 dockerLinux does not seem to be running inside a container
      $ docker run -t -d -u 1000:1000 -w /home/agent/workspace/ation_test_dockertestexecute -v /home/agent/workspace/ation_test_dockertestexecute:/home/agent/workspace/ation_test_dockertestexecute:rw,z -v /home/agent/workspace/ation_test_dockertestexecute@tmp:/home/agent/workspace/ation_test_dockertestexecute@tmp:rw,z -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** alpine:latest cat
      [Pipeline] {
      [Pipeline] powershell
      $ docker top <hguid> -eo pid,comm

        Attachments

          Activity

          Hide
          chiranth Chiranth Bagivalu Ramaswamy added a comment -

          Update: I have also tested with a different image i.e docker.image("julkwiec/dotnet-mono-powershell-build:latest") and the issue is still the same.
          Could anyone help look into the issue?

          Show
          chiranth Chiranth Bagivalu Ramaswamy added a comment - Update: I have also tested with a different image i.e docker.image("julkwiec/dotnet-mono-powershell-build:latest") and the issue is still the same. Could anyone help look into the issue?
          Hide
          pjdarton pjdarton added a comment -

          The fact that the sh step worked tells us that this isn't a problem with the docker-plugin; that's telling us that the docker-plugin successfully created a container, and a matching Jenkins node, and joined the two up so that Jenkins was able to run build steps on the container ... and that's the end of the docker-plugin's responsibilities.

          My guess is that the powershell step doesn't play nicely with docker containers, and that's not really something that the docker-plugin can do anything about.

          What I'd suggest you do is manually create a docker container based on your chosen image, manually create a Jenkins (JNLP) slave node with some label of your choosing, and then run the Jenkins slave.jar process under your control within the docker container, logging absolutely everything it does.

          i.e. log all process-creation commands etc so you can see exactly what gets run by whom and when.

          ...and then try running the sh and powershell steps from Jenkins (targetting that node via its label) and see what happens.

          Show
          pjdarton pjdarton added a comment - The fact that the sh step worked tells us that this isn't a problem with the docker-plugin; that's telling us that the docker-plugin successfully created a container, and a matching Jenkins node, and joined the two up so that Jenkins was able to run build steps on the container ... and that's the end of the docker-plugin's responsibilities. My guess is that the powershell step doesn't play nicely with docker containers, and that's not really something that the docker-plugin can do anything about. What I'd suggest you do is manually create a docker container based on your chosen image, manually create a Jenkins (JNLP) slave node with some label of your choosing, and then run the Jenkins slave.jar process under your control within the docker container, logging absolutely everything it does. i.e. log all process-creation commands etc so you can see exactly what gets run by whom and when. ...and then try running the sh and powershell steps from Jenkins (targetting that node via its label) and see what happens.
          Hide
          dmcminn Drew McMinn added a comment - - edited

          Having this exact same problem.

           

          withDockerContainer(image: 'mcr.microsoft.com/powershell', toolName: 'docker', args: '--entrypoint=""')
          {  
               powershell label: '', returnStdout: true, script: 'write-host "test"'
          }
          

           

           

          Show
          dmcminn Drew McMinn added a comment - - edited Having this exact same problem.   withDockerContainer(image: 'mcr.microsoft.com/powershell' , toolName: 'docker' , args: '--entrypoint=""' ) {   powershell label: '', returnStdout: true , script: ' write-host "test" ' }    
          Hide
          duemir Denys Digtiar added a comment -

          Changing the component to durable-task since that is what implements the powershell step, not the PowerShell plugin.

          Show
          duemir Denys Digtiar added a comment - Changing the component to durable-task since that is what implements the powershell step, not the PowerShell plugin.

            People

            • Assignee:
              Unassigned
              Reporter:
              chiranth Chiranth Bagivalu Ramaswamy
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated: