Using Multiple shell commands with interpolation

Usually when executing multiple shell commands i use multiline strings:

bat """
-cmd1
-cmd2 ...
"""

but when using withCredentials[…]
i have to do bat 'cmd %credential% cmd2' to interpolate correctly

But this gives me an error because it just sees it as one command. What is the correct way to do this?

Jenkins setup:Jenkins 2.426.1

bat '''
cmd %credential% 
cmd2
'''

but for windows batch you can also use double quotes I think as %variable% is not interpolated by groovy so it reaches as is the windows batch

Indeed, works. But one more question

when i defined a normal variable how do i use it in there as well?

def path = "path\\folder"
with Credentials [...] {
bat '''
cd %path%
cmd %credential% 
cmd2
'''
}

the path evaluates to nothing here

Yes double quotes work too but interpolate unsafely and give a warning.

withEnv(["path=path\\folder"]) {
  with Credentials [...] {
    bat '''
    cd %path%
    cmd %credential% 
    cmd2
    '''
  }
}