Q:

Use simple and double triple quote in groovy script

I have this code in groovy script: 
script = ''' 
def val1 = 'val1' 
def val2 = 'val2' 
def cmd = """ cd /path/to/my/folder && python -c 'import MyClass; MyClass.my_method(\"${val1}\",\"${val2}\")' 
"""
def proc = ["bash", "-c", command].execute()
proc.waitFor()
print proc.in.text 
'''; 

I want to use parameter outside the script : 
def val1 = 'val1' 
def val2 = 'val2' 
script = ''' 
def cmd = """ 
cd /path/to/my/folder && python -c 'import MyClass; MyClass.my_method(\"${val1}\",\"${val2}\")' 
""" 
def proc = ["bash", "-c", command].execute()
proc.waitFor()
print proc.in.text
'''; 

I try to combine simple and double triple quote but it is not working, do you have any idea how I can solve this problem ? 
I want to use parameter outside the script : 
def val1 = 'val1' 
def val2 = 'val2' 
script = """ 
def cmd = """ 
cd /path/to/my/folder && python -c 'import MyClass; MyClass.my_method(\"${val1}\",\"${val2}\")' 
""" 
def proc = ["bash", "-c", command].execute()
proc.waitFor()
print proc.in.text
""";

A:

I wonder if this is what you need: triple double quotes on the outside to enable the placeholder replacement
def val1 = 'val1' 
def val2 = 'val2' 
script = """ 
    def cmd = '''
        if cd /path/to/my/folder; then
            python -c 'import MyClass; MyClass.my_method("${val1}","${val2}")' 
        fi
    '''
    def proc = ["bash", "-c", command].execute()
    proc.waitFor()
    print proc.in.text
"""

