I am trying to create a Jenkins pipeline where I need to execute multiline shell commands.
stage ('Test'){
name="myserver"
sh '''
"ssh -o StrictHostKeyChecking=no ${myserver} 'rm -rf temp && mkdir -p temp && mkdir -p real'"
'''
}
But it is always returning error as "command not found". If I run the same with
sh "ssh -o StrictHostKeyChecking=no ${myserver} 'rm -rf temp && mkdir -p temp && mkdir -p real' "
Is there a different way to access variable in multiline shell?
You need to use """ like this:
sh """
"ssh -o StrictHostKeyChecking=no ${myserver} 'rm -rf temp && mkdir -p temp && mkdir -p real'"
"""
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