I have some groovyscript. I execute a shell command:
sh "echo ${myParams.TEST}"
This prints:
works
Now I try to do the same but in a bash script in the shell:
sh'''#!/bin/bash
echo "${myParams.TEST}"
'''
But this gives always the same error: bad substitution
EDIT:
sh """#!/bin/bash
echo \"${myParams.TEST}\"
"""
This works: output is: works
Now I try:
sh """. ./script.sh"""
script.sh looks like:
#!/bin/bash
echo "hey"
echo '\"${myParams.TEST}\"'
Output is again:
hey
bad substitution
sh """../script.sh"""
just starts shell script
and shell script don't know anything about your groovy variables
so, you have to pass values to your script like this:
sh """../script.sh \"${myParams.TEST}\" """
then you can access the value of myParams.TEST in bash by $1 as it is the first parameter for it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With