I have a first step in my pipeline for parameters verification. isEmpty() method is called against all parameter that shouldn't be empty. Unfortunetly isEmpty() method generates an exception when it is called to check a "password" type parameter. Same method work well with "choice" and "text" parameters types.
Exception
hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: hudson.util.Secret.isEmpty() is applicable for argument types: () values: []
jenkinsFile
pipeline {
agent any
parameters {
choice(
choices: ["","TEST","PRODUCTION"],
description: 'Application',
name: 'ENV'
)
text(
name: 'FILE_LIST',
defaultValue: '',
description: 'Files'
)
password(
name: 'CREDENTIAL_ID',
defaultValue: '',
description: "Jenkins credential ID for application"
)
}
stages {
stage("Parameters check") {
steps {
script {
// This one is OK
if (params.ENV.isEmpty()) {
currentBuild.result = 'ABORTED'
error("ENV is empty")
}
// This one is also OK
if (params.FILE_LIST.isEmpty()) {
currentBuild.result = 'ABORTED'
error("FILE_LIST is empty")
}
// This throws an exception
if (params.CREDENTIAL_ID.isEmpty()) {
currentBuild.result = 'ABORTED'
error("CREDENTIAL_ID is empty")
}
}
}
}
}
}
How to check if password parameter is empty and where is it documented?