I am trying to use string parameter but it is always creating new line even when I am using trim()
I followed solution from Jenkins Pipeline - inserting variable in shell creates a new line
Pipeline Code
parameters {
string(defaultValue: '', description: 'url', name: 'Url')
}
environment {
KEY = credentials('KEY')
USERNAME = credentials('USERNAME')
PASSWORD = credentials('PASSWORD')
//Parameters
URL = "${params.Url.trim()}"
}
stage('Run script to upload image') {
steps {
script {
sh '''
if [ -n "${URL}" ]; then
./create_and_upload_image.sh --url ${URL} --uname ${USERNAME} --password ${PASSWORD} --key ${KEY}"
fi
//More steps
'''
}
}
}
Output
+ [ -n
https://access.cdn.com/content/origin/files/sha256/4e/4e5c7cccb5ea7622640c97725912222458af743cf994e48f10239734c6a2ee65/image.qcow2 ]
+ ./create_and_upload_image.sh --url
https://access.cdn.com/content/origin/files/sha256/4e/4e5c7cccb5ea7622640c97725912222458af743cf994e48f10239734c6a2ee65/image.qcow2 --uname **** --password **** --key ****
bash: --uname: command not found
What should I do to avoid new line
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…