• Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • docker
    • None

      sh command not working wile specifying user to run inside contrainer.
      Example:

      docker.image('node:latest').inside('--user node') {
      stage('Pull repository') {    
          sh 'whoami'
      }    
      

      In this case checkout and other jenkins functions is working, but not any of sh

      Process is pending for 5 minutes and then return:

      process apparently never started in /var/lib/jenkins/workspace/contrail-ui/contrail-ui-builder@2@tmp/durable-ae2b4ade (running Jenkins temporarily with -Dorg.jenkinsci.plugins.durabletask.BourneShellScript.LAUNCH_DIAGNOSTICS=true might make the problem clearer)
      

      Error appears to be with any container.

       

          [JENKINS-58657] sh not working inside docker container

          Erik Wegner added a comment -

          This seems somewhat related to https://github.com/jenkinsci/docker/issues/626#issuecomment-508444712

          In my scenario, there are two containers on a kubernetes pod, one is the jnlp-slave.
          The directory /home/jenkins/agent/workspace/<jobname>@tmp/durable-831063bb exists and is used for steps running inside the jnlp-container.
          The sh-step running inside the other container tries to access the wrong directory and outputs these messages:

          sh: 1: cannot create /home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-log.txt: Permission denied
          sh: 1: cannot create /home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-result.txt.tmp: Permission denied
          touch: cannot touch '/home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-log.txt': Permission denied
          mv: cannot stat '/home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-result.txt.tmp': No such file or directory
          touch: cannot touch '/home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-log.txt': Permission denied
          

          Erik Wegner added a comment - This seems somewhat related to https://github.com/jenkinsci/docker/issues/626#issuecomment-508444712 In my scenario, there are two containers on a kubernetes pod, one is the jnlp-slave . The directory /home/jenkins/agent/workspace/<jobname>@tmp/durable-831063bb exists and is used for steps running inside the jnlp-container. The sh -step running inside the other container tries to access the wrong directory and outputs these messages: sh: 1: cannot create /home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-log.txt: Permission denied sh: 1: cannot create /home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-result.txt.tmp: Permission denied touch: cannot touch '/home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-log.txt': Permission denied mv: cannot stat '/home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-result.txt.tmp': No such file or directory touch: cannot touch '/home/jenkins/agent/workspace/<jobname>@tmp/durable-6535bde4/jenkins-log.txt': Permission denied

          Erik Wegner added a comment -

          Update: the directory was created, but for the wrong user. The directory was created by/for user id 1000, but my second container was using id 10000. The directory's permissions are set to 0x755.

          Updating the Dockerfile helped to run the script again.

          Erik Wegner added a comment - Update: the directory was created, but for the wrong user. The directory was created by/for user id 1000, but my second container was using id 10000. The directory's permissions are set to 0x755. Updating the Dockerfile helped to run the script again.

          Anatoly Basov added a comment -

          I have run into this issue too. In my case the problem was an empty env variable.

          I have made a PR https://github.com/jenkinsci/docker-workflow-plugin/pull/185

          Anatoly Basov added a comment - I have run into this issue too. In my case the problem was an empty env variable. I have made a PR https://github.com/jenkinsci/docker-workflow-plugin/pull/185

            csanchez Carlos Sanchez
            szhyhalo Oleksandr Zhyhalo
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: