Asking for passwords in Jenkins pipeline files

Viewed 6109

I have a Jenkinsfile that needs to ask for a password.

I have the following:

def password = input message: 'Please enter the password', parameters: [string(defaultValue: '', description: '', name: 'password')]

The problem is that the field shows up the characters in Jenkins when I type them in meaning anyone looking over my shoulder can see them.

The value is also logged clearly in the logfile.

Is there a way that I can:

  1. mask the characters as they are typed in the field?
  2. hide the value in the log file?
2 Answers

@hayderimran7 was almost there but did not address my comment in his answer so posting it here.

Use a password parameter as following:

input message: 'enter password', parameters: [password(defaultValue: 'value', description: '', name: 'hidden')]

Related