Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Declarative pipeline

Tips

  • Escaping symbols ' single quote
def text = '"\$ENV1, \$ENV2"';

pipeline {
    agent any;
    stages {
        stage("Escaping single quote") {
            steps {
                sh """
                    bash -c ' echo '"'"'${text}'"'"' '
                """
            }
        }
    }
}

// Output
// [Pipeline] sh (hide)
// + bash -c ' echo '\''"$ENV1, $ENV2"'\'' '
// "$ENV1, $ENV2”