Jenkins declarative pipeline mask parameter password in console logs
I was able to mask the password in console logs, below is the working code:
pipeline { agent none options { skipDefaultCheckout() skipStagesAfterUnstable() } parameters { string(name: 'userid', defaultValue: 'master', description: 'Enter User ID') password(name: 'passwd', defaultValue: 'secret', description: 'Enter Password') } stages { stage('Test') { agent { label 'someLabel' } steps { script { wrap([$class: 'MaskPasswordsBuildWrapper', varPasswordPairs: [[password: "${passwd}", var: 'PSWD']]]) { sh '''echo PSWD: ${passwd}''' } } } } }}