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)
            node ('master'){
                stage('Git Checkout'){
                    checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], userRemoteConfigs: [[credentialsId: 'mycrednetial', url: 'myurl']]])

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?


I have just managed how to escape characters.

The solution is to add: "\" before the character.

  • Could you mark this answer as resolved if this solved the issue?
    – 030
    Sep 7 '17 at 12:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.