Syntax for running sed in a Jenkins pipeline?
19:13 22 Feb 2026

I run the following script in a Jenkins pipeline

sh(label: "Build Docker image",
    script: """
        sed -i \\'s/NEXUS_VERSION/${env.NEXUS_VERSION}/g\\' Dockerfile.nexus
        cat Dockerfile.nexus
    """,
    returnStatus: true)

The sed command works on my terminal, without the extraneous \\ . But I get the following error when I run it in a pipeline.

sed: -e expression #1, char 1: unknown command: `''

What's the correct sytax? Thanks!

jenkins groovy jenkins-pipeline