Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Seperate sh command in multiple lines

I have a sh command in jenkinsfile.

sh 'command1 command2'

How to write this in multiple lines?

sh '''
command1 \
command2
'''

or

sh '''
command1 &&
command2
'''
like image 618
Shanmukh Borole Avatar asked Jun 27 '26 22:06

Shanmukh Borole


2 Answers

The solution is :

sh """
command1 \\
command2 \\
"""

That worked for me.

like image 108
Shanmukh Borole Avatar answered Jun 30 '26 20:06

Shanmukh Borole


I think that you should mix both:

sh '''
command1 && \
command2
'''

&& allows another command

\ tells to shell to ignore the following character (the new line)

like image 25
avalla Avatar answered Jun 30 '26 19:06

avalla