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

withCredentials(FileBinding){} ignored when executed in docker.image().inside{...}

XMLWordPrintable

      withCredentials(FileBinding){...} is ignored in docker.image('cloudbees:java-build-tools').inside{...}. The same withCredentials step works in 'standard' linux node.

      See logs below.

      It seems to be because FileBinding#secretsDir() creates a "secretFiles" directory under "node.getRootPath()" that is not 'mounted' in the docker container.

      withCredentials(FileBinding){...} ignored in docker.image(...).inside{...} 
      docker.image('busybox').inside{
          withCredentials([[$class: 'FileBinding', credentialsId: 'secret-file', variable: 'SECRET_FILE']]) {
              sh 'ls -al $SECRET_FILE'
          }
      }
      
      Started by user Cyrille Le Clerc
      [Pipeline] Allocate node : Start
      Running on vagrant in /home/vagrant/jenkins/workspace/test-credentials-binding
      [Pipeline] node {
      [Pipeline] sh
      [test-credentials-binding] Running shell script
      + docker inspect -f . busybox
      .
      [Pipeline] Run build steps inside a Docker container : Start
      $ docker run -t -d -u 1000:1000 -w /home/vagrant/jenkins/workspace/test-credentials-binding -v /home/vagrant/jenkins/workspace/test-credentials-binding:/home/vagrant/jenkins/workspace/test-credentials-binding:rw -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** -e ******** busybox cat
      [Pipeline] withDockerContainer {
      [Pipeline] Bind credentials to variables : Start
      [Pipeline] withCredentials {
      [Pipeline] sh
      [test-credentials-binding] Running shell script
      + ls -al ****
      ls: ****: No such file or directory
      

            jglick Jesse Glick
            cleclerc Cyrille Le Clerc
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: