Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between """ and ''' in terms of running a shell script within a Jenkins pipeline step?

In Jenkins pipeline, what's the difference between:

sh """
...
...
... 
"""

and

sh '''
...
...
... 
'''

Thanks in advance

like image 601
Itai Ganot Avatar asked Sep 05 '16 15:09

Itai Ganot


People also ask

What is the step that runs Unix shell scripts in Jenkins pipelines?

On Linux, BSD, and Mac OS (Unix-like) systems, the sh step is used to execute a shell command in a Pipeline.

What is the difference between scripted and declarative pipeline?

Declarative pipelines break down stages into individual stages that can contain multiple steps. Scripted pipelines use Groovy code and references to the Jenkins pipeline DSL within the stage elements without the need for steps.

What is node in Jenkins pipeline script?

A node is a machine which is part of the Jenkins environment and is capable of executing a Pipeline. Also, a node block is a key part of Scripted Pipeline syntax.


1 Answers

Both are multi-line strings

The first multi-line string with """ can be templated into a GroovyString

The second one with ''' cannot (and is just a java String with newlines)

I have linked to the relevant documentation

like image 167
tim_yates Avatar answered Oct 05 '22 06:10

tim_yates