I need to check if string exists in an array of strings, in a Jenkins Declarative pipeline step.
I cannot find any documentation on operators, except some groovy docs, which suggest using !in, but that does not work, so not sure if those apply here. This is what I tried and it is not working, !in is not regocnized:
def approvalResult
pipeline {
....
stage('Setup') {
steps {
script {
approvalResult = input message: 'Approve prod deployment',
submitter: 'john@example.com',
submitterparameter: ''
echo "Build was approved by ${approvalResult}"
//approvalResult contains string with the user email who clicked approve
if(${approvalResult} !in ['john@example.com','admin@example.com']){
error("This user is not approved to deploy to PROD.")
}
}
}
}
}