I am using bash script inside Groovy in the Jenkins pipeline. Jenkins job is parameterized and using a password parameter option named "PASSWORD". The issue is when password contains "$" sign, then it is getting escaped in the bash script. For example: Actual password inputed is "ppa$$worddd" but in the bash script $PASSWORD value is "ppa$worddd". As we could see one "$" is removed. Please look at the code below. Please help
def password = params.get('PASSWORD')
stage('execute') {
steps {
script {
println password // - Here value is "ppa$$worddd" as expected
withCredentials([string(credentialsId: 'ID', variable: 'C_ID'),string(credentialsId: 'SE', variable: 'C_SE')]) {
if (!starsValue.isEmpty()) {
sh '''
cd Scripts
echo $PASSWORD // - Here value is "ppa$worddd" .As seen one "$" is removed
'''
}
}
}
}
}
"ppa$worddd"by'ppa$worddd'!PASSWORDenvironment variable? your code snippet is not stowing this. according to documentation you can do something likeenvironment { PASSWORD=password }before sh command to set env variable jenkins.io/doc/book/pipeline/jenkinsfile/…