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

secret file not accesible to containerized stages

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Minor Minor
    • None
    • operating system: Debian GNU/Linux 8.11 (jessie)
      jenkins version: 2.121.3
      java version 1.8.0_181, oracle

      accessing files stored as secret files via the credentials plugin fails when running in a pipeline where only the particular stage is running in a docker container.

       
      how to reproduce:

      upload a file with the content "secret" via the credentials plugin:

      credentials -> system -> global credentials -> add credentials -> secret file
      

      access it via a pipeline which is containiserized on the top level:

      #!groovy
      
      pipeline {
      	agent {
      		docker {
      			label "worker"
      			image "alpine:3.8"
      		}
      	}
      	environment {
      		SECRET = credentials("secret")
      	}
      	stages {
      		stage("cat") {
      			steps {
      				sh "cat $SECRET"
      			}
      		}
      	}
      }
      

      this results in the expected log output:

      [...]
      [project_master-IVL6IBXNKWVTPPV72MKSLBHB5K2X7C74P6THVIE7VGCZ2TT2GNOQ] Running shell script
      + cat ****
      secret
      [...]
      

      access it via a pipeline where only a particular stage is containerized:

      #!groovy
      
      pipeline {
      	agent {label "worker"}
      	environment {
      		SECRET = credentials("secret")
      	}
      	stages {
      		stage("cat") {
      			agent {
      				docker {
      					label "worker"
      					image "alpine:3.8"
      				}
      			}
      			steps {
      				sh "cat $SECRET"
      			}
      		}
      	}
      }
      

      this results in the following error:

      [...]
      [project_master-IVL6IBXNKWVTPPV72MKSLBHB5K2X7C74P6THVIE7VGCZ2TT2GNOQ@2] Running shell script
      + cat ****
      cat: can't open '****': No such file or directory
      [...]
      

          [JENKINS-54573] secret file not accesible to containerized stages

          jens stein created issue -

            Unassigned Unassigned
            jsj jens stein
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated: