title: How to mask a password field in Jenkins Pipeline project?
body: <p>When a password property is defined in a <code>Jenkinsfile</code>:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>properties([
      parameters([
          password(name: 'KEY', description: 'Encryption key')
      ])
  ])
  </code></pre>
  
  <p>Jenkins prompts users to provide its value every time the pipeline is executed:</p>
  
  <p><a href="https://i.stack.imgur.com/vkuc7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/vkuc7.png" alt="Build parameters"></a></p>
  
  <p>I want this parameter to be masked so that <code>echo ${KEY}</code> does not print the actual value passed by the user. However, at the moment echoing it prints the provided value verbatim:</p>
  
  <pre class="lang-groovy prettyprint-override"><code>properties([
      parameters([
          password(name: 'KEY', description: 'Encryption key')
      ])
  ])
  
  node {
      stage('Stage 1') {
          # Will print the actual value of the KEY, verbatim
          sh "echo ${KEY}"
      }
  }
  </code></pre>
  
  <p>Also it seems that the Mask Passwords plugin does not work with Jenkins pipelines, so using that is not an option.</p>
  
  <p>Is there a way to mask these password-typed parameters in the build logs?</p>