<p>I have just managed how to escape characters.</p>

<p>The solution is to add: "\" before the character.</p>

<pre><code>checkout([\$class:....
</code></pre>

CC BY-SA 3.0
2017-09-07T12:39:15.337Z
Could you mark this answer as resolved if this solved the issue?
030
CC BY-SA 4.0
2021-11-02T21:28:07.143Z
I tried you suggestion for the following case: `wrap([$class: 'BuildUser'])` but got `nexpected char : '\'`
arielma
CC BY-SA 3.0
2017-09-04T13:39:42.980Z
2017-09-04T13:39:42.980Z
joudaon
<p>I have the following DSL code and I´m getting error on line 13, <code>$class</code>. I guess than everything inside <code>script("""...""")</code> is parsed as plain text to the pipeline definition but I don´t know what´s wrong or how to escape the <code>$</code> character.</p>

<p>My code:</p>

<pre><code>pipelineJob('DSL-Test') {

parameters {
    choiceParam ('version', ['1.2.1', '1.2.0'], 'Docker Version')
}

definition {
    cps {
        sandbox(boolean sandbox = true)
        script("""
            node ('master'){
                stage('Git Checkout'){
                    checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'mycrednetial', url: 'myurl']]])
                }
            }
        """.stripIndent()) 
         }
    }
}
</code></pre>

<p>This is the error I get:</p>

<blockquote>
  <p>Processing provided DSL script ERROR: startup failed: script: 13:
  unexpected token: class @ line 13, column 24.
                            checkout([$class: 'GitSCM'])
                            ^</p>
  
  <p>1 error</p>
  
  <p>Started calculate disk usage of build Finished Calculation of disk
  usage of build in 0 seconds Started calculate disk usage of workspace
  Finished Calculation of disk usage of workspace in 0 seconds Finished:
  FAILURE</p>
</blockquote>

<p>Does anyone know how to make that character not display error?</p>

<jenkins><job-dsl>
Jenkins DSL - Pipeline Job (Unexpected token '$')
joudaon
# Jenkins DSL - Pipeline Job (Unexpected token '$')

(Asked by: username_0 on 2017-09-04)

I have the following DSL code and I´m getting error on line 13, $class. I guess than everything inside script("""...""") is parsed as plain text to the pipeline definition but I don´t know what´s wrong or how to escape the $ character.
My code:
pipelineJob('DSL-Test') {

parameters {
    choiceParam ('version', ['1.2.1', '1.2.0'], 'Docker Version')
}

definition {
    cps {
        sandbox(boolean sandbox = true)
        script("""
            node ('master'){
                stage('Git Checkout'){
                    checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'mycrednetial', url: 'myurl']]])
                }
            }
        """.stripIndent()) 
         }
    }
}

This is the error I get:

Processing provided DSL script ERROR: startup failed: script: 13:
  unexpected token: class @ line 13, column 24.
                            checkout([$class: 'GitSCM'])
                            ^
1 error
Started calculate disk usage of build Finished Calculation of disk
  usage of build in 0 seconds Started calculate disk usage of workspace
  Finished Calculation of disk usage of workspace in 0 seconds Finished:
  FAILURE

Does anyone know how to make that character not display error?

**Tags:** jenkins, job-dsl


---

## 1 answers

### Answer by username_0 on 2017-09-04. Score: 0 | Accepted answer

I have just managed how to escape characters.
The solution is to add: "\" before the character.
checkout([\$class:....

> **Comments:**
> **username_1**: Could you mark this answer as resolved if this solved the issue?  
> **username_2**: I tried you suggestion for the following case: `wrap([$class: 'BuildUser'])` but got `nexpected char : '\'`  

---

