Punter Vicky
Punter Vicky

Reputation: 16982

Defining shell variables in a jenkins shell script

I see the below error when I try to create a shell variable in my JenkinsFile. How can I get around this issue?

groovy.lang.MissingPropertyException: No such property: file_name for class: Script1

  sh"""
    file_name=`echo ${env.JOB_NAME} | sed -e 's/\\//-/g'`
    echo "file name =" $file_name
  """

Upvotes: 0

Views: 770

Answers (1)

Punter Vicky
Punter Vicky

Reputation: 16982

This post helped me get the issue fixed. I had to do the below -

 sh"""
    file_name=`echo ${env.JOB_NAME} | sed -e 's/\\//-/g'`
    echo "file name =" \$file_name
  """

Upvotes: 1

Related Questions