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

Surpassing secrets interpolation warning in writeFile

XMLWordPrintable

      Straight to example:

      withCredentials([usernamePassword(
          credentialsId: 'PVS-credentials',
          usernameVariable: 'PVS_USER',
          passwordVariable: 'PVS_SERIAL'
      )]) {
          node('meta-job') {
              writeFile(
                  file: 'config.ini',
                  text: "${PVS_USER}\n${PVS_SERIAL}\n${JOB_NAME}-${BUILD_NUMBER}",
              )
          }
      }
      

      This causes:

      17:43:29  Warning: A secret was passed to "writeFile" using Groovy String interpolation, which is insecure.
      17:43:29  		 Affected argument(s) used the following variable(s): [PVS_SERIAL, PVS_USER]
      17:43:29  		 See https://jenkins.io/redirect/groovy-string-interpolation for details.
      

      Yes, writing credentials to files is bad, but unfortunately there are examples of software that operate like this, so... What do? Storing whole files as a secrets is not an option (they may contain additional dynamical data), and I would rather not dug into various templaters like Jinja or groovy's inhouse one.

            Unassigned Unassigned
            artalus Artalus S.
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: