Reputation: 5976
I create a function in Jenkinsfile as below
def image_exists(repo_name){
sh '''#!/bin/bash
echo "${repo_name}" && echo "TEST" '''
}
It print TEST but it print blank line instead of repo_name What should I do to print repo_name? I try
echo $repo_name
echo ${repo_name}
echo repo_name
I call it by
IMAGE_EXIST=image_exists("test")
Upvotes: 0
Views: 701
Reputation: 4923
try to use double-quotes after sh
command, single quotes do not support interpolation:
def image_exists(repo_name){
sh """
#!/bin/bash
echo \"${repo_name}\" && echo \"YYY\"
"""
}
Upvotes: 4