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

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

    XMLWordPrintable

    Details

    • Similar Issues:

      Description

      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
      

        Attachments

          Issue Links

            Activity

            Hide
            jglick Jesse Glick added a comment -

            A facet of JENKINS-27152.

            Show
            jglick Jesse Glick added a comment - A facet of JENKINS-27152 .
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/java/org/jenkinsci/plugins/credentialsbinding/impl/FileBinding.java
            http://jenkins-ci.org/commit/credentials-binding-plugin/8661953085e98b71a5f2eaa3c191d4cecd3b66f4
            Log:
            JENKINS-32943 Use a standardized temporary directory for secretFiles.

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/org/jenkinsci/plugins/credentialsbinding/impl/FileBinding.java http://jenkins-ci.org/commit/credentials-binding-plugin/8661953085e98b71a5f2eaa3c191d4cecd3b66f4 Log: JENKINS-32943 Use a standardized temporary directory for secretFiles.
            Hide
            scm_issue_link SCM/JIRA link daemon added a comment -

            Code changed in jenkins
            User: Jesse Glick
            Path:
            src/main/java/org/jenkinsci/plugins/credentialsbinding/impl/FileBinding.java
            src/main/resources/org/jenkinsci/plugins/credentialsbinding/impl/BindingStep/help.html
            src/test/java/org/jenkinsci/plugins/credentialsbinding/impl/BindingStepTest.java
            http://jenkins-ci.org/commit/credentials-binding-plugin/ed93648cf8404ad67d7d69ffeb76f5da83c96e2a
            Log:
            Merge pull request #13 from jglick/temp-dir-JENKINS-27152

            JENKINS-32943 Use a standardized temporary directory for secretFiles

            Compare: https://github.com/jenkinsci/credentials-binding-plugin/compare/689655d67923...ed93648cf840

            Show
            scm_issue_link SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: src/main/java/org/jenkinsci/plugins/credentialsbinding/impl/FileBinding.java src/main/resources/org/jenkinsci/plugins/credentialsbinding/impl/BindingStep/help.html src/test/java/org/jenkinsci/plugins/credentialsbinding/impl/BindingStepTest.java http://jenkins-ci.org/commit/credentials-binding-plugin/ed93648cf8404ad67d7d69ffeb76f5da83c96e2a Log: Merge pull request #13 from jglick/temp-dir- JENKINS-27152 JENKINS-32943 Use a standardized temporary directory for secretFiles Compare: https://github.com/jenkinsci/credentials-binding-plugin/compare/689655d67923...ed93648cf840

              People

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

                Dates

                • Created:
                  Updated:
                  Resolved: