12

I have the following dsl

pipeline { agent { label 'test' } parameters { booleanParam(defaultValue: false, description: 'This is a Release build', name: 'isRelease') } stages { stage('Build') { steps { script { if (${params.isRelease}) { echo("This is a release") } } } } } } 

This fails with the following error

java.lang.NoSuchMethodError: No such DSL method '$' found among steps 

What I am doing wrong? I am using

  • Jenkins 2.89.4
  • Job DSL 1.68
  • Pipeline Job 2.20
  • Pipeline: API 2.27
  • Pipeline: Basic Steps 2.7
  • Pipeline: Build Steps 2.7
  • Pipeline: Declarative 1.2.9

1 Answer 1

20

Ok the answer can already be found in Stackoverflow: Boolean parameter are in reality strings, so this works

if ("${params.isRelease}" == "true") { echo("This is a release") } 

Alternatively use the params-object

if (params.isRelease) { echo("This is a release") } 
Sign up to request clarification or add additional context in comments.

1 Comment

In my case I had print statement inside a stage like this. println("Getting environment:"+${environment}) Issue fixed after modifying to this. println("Getting environment:${environment}")

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.