Jenkins pipeline single quotes, double quotes, and escape character

Jenkins pipeline single quotes, double quotes, and escape character

Foreword

Jenkins pipeline consistent syntax single quotes, double quotes, and escape character syntax and Linux shell in.

apostrophe'

In all special characters between single quotes loses its special meaning

Double quotes"'

In most of the special characters between the double quotes loses its special meaning, except for the following exceptions:

  • $ No dollar value is used to extract variables
  • `Execute commands with anti-colon
  • \ To escape the backslash character

Jenkins pipeline examples

Example 1: I have $ 100 print

echo 'I have $100'
echo "I have \$100"

Example 2: Printing PATH environment variable

echo "PATH = ${PATH}"

Example 3: Print It's a dog.

echo "It's a dog"

Example 4: View python process ID

sh "ps -ef | grep python | grep -v grep | awk \'{print \$2}\'"

Example 5: execute multiple commands

sh """
    whoami
    pwd
    ls -ltra
"""

or

sh '''
    whoami
    pwd
    ls -ltra
'''

summary

In Jenkins pipeline, if no special characters, single and double quotes is the same, if you want to execute multiple lines of command, with three single quotes or three double quotes.

If there are special characters that require interpretation, use double quotes.

If necessary escaped with\Escapes.

Reference Documents

Intelligent Recommendation

+ Single quotes double quotes: parameter passing problem escape

today encountered a strange bug, there is a button on a table, the code that is returned by the js I passed to the function onClick event inside a parameter on the page, these "details" butt...

1-5 Single quotes, double quotes and escape characters

1. Single quotation marks, double quotation marks (suitable for processing strings with relatively simple format) For example, if we want to output "hello world" on the screen, we can start ...

BASH quotation marks and escape - the difference between single quotes, double quotes

The following two commands although the execution result is the same, the processing process is different, and this article is read and thinking about where they are different.   Normal mode ( \ ...

Single quotes, double quotes and escape characters in PHP (transfer)

Why can't 80% of the code farmers can't do architects? >>>   Both PHP single quotes and dual quotes can modify string type data, if the modified string contains variables (Example $...

Linux single and double quotes and escape symbols

Q1 Symbols in single quotes will not be escaped Variables cannot be quoted in single quotes in Linux, use''''You can use single quotes to quote variables. Q2 use=Assignment will cause escape character...

More Recommendation

Single quotes, double quotes, and back single quotes (`)

Since it can be written like this, it happened by chance (the guess should be ES6)    ...

Golang single quotes and double quotes and back quotes

In golang, strings are implemented in byte arrays at the bottom, and double quotes or backquotes are used in golang to represent strings. The backquotes are output as they are and are not escaped.Inse...

Python single quotes, double quotes, triple quotes

Single quotes '' in Python, double quotes "", triple quotes """ """, or ''' ''' can be used to contain strings, three quotes can contain strings of multiple lin...

Single quotes, double quotes, triple quotes in python

Single quotes are used to escape, double quotes are used to enclose strings, and triple quotes are used for free line breaks. It does not matter if you use single and double quotation marks for string...

Single quotes, double quotes, non-quotes and demo

Special symbol apostrophe ' ' Double quotes " " Do not quote Anti-quotes `` apostrophe ' ' What you have come here, eat spit The command and scripting inside will not be executed You can see...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top