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

Pipeline withCredentials step does not mask step descriptions for variables with the same name as existing system variables

    Details

    • Similar Issues:

      Description

      There seems to be an issue with the Pipeline step withCredentials and how it masks variables.

      It seems that when a variable name already exists in the current environment, the step description masking is skipped and the variables are rendered as clear text.

      In the console log, the steps are masked correctly (the step description is not included anyway).

      I first observed this happening in the Blue Ocean UI as part of a script pipeline job.

      As a workaround, using a script seems to hide the step description (for shell cmds at least).

      Pipeline code to reproduce:

      pipeline {
          agent any
          
          stages {
              stage('test withCredentials bug'){
                  steps {
                      withCredentials([usernameColonPassword(credentialsId: 'withCredentialsBug', variable: 'USER')]) {
                          sh "echo '$USER'"
                          sh './user.sh'
                      }
                      
                      withCredentials([usernameColonPassword(credentialsId: 'withCredentialsBug', variable: 'USRPWD')]) {
                          sh "echo '$USRPWD'"
                          sh './user.sh'
                      }
                  }
              }
          }
      }
      

      user.sh helper script exists in the workspace:

      echo "\$USERPWD = $USRPWD"
      echo "\$USER = $USER"
      

      I've attached some screenshots below.

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                Unassigned
                Reporter:
                catalin_cretu Catalin Cretu
              • Votes:
                4 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated: