Home > Enterprise >  No such DSL method '$' found among steps - env.CHANGE_BRANCH
No such DSL method '$' found among steps - env.CHANGE_BRANCH

Time:11-22

I have a condition in my groovy file, which checks if env.CHANGE_BRANCH is not equal null. In that case variable branch is set as env.CHANGE_BRANCH, otherwise branch is env.BRANCH_NAME.

When env.CHANGE_BRANCH is null I get a following error:

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

def branch = ""
script {
   if (env.CHANGE_BRANCH != null) {
                        branch = env.CHANGE_BRANCH
                    } else {
                       branch = env.BRANCH_NAME
                    }
    echo "Print branch"
}
    echo ${branch}

CodePudding user response:

Your echo statement has to be in double quotes for string interpolation to work.

echo "${branch}"

or do

println branch

CodePudding user response:

thanks a lot for your answer, it work.

  • Related