Alex
Alex

Reputation: 440

How to use environment variable in script statement with triple quoted string Jenkins?

I'm trying to call a variable in my Jenkinsfile from a script statement with triple double-quotes string as shown below:

sh(script: """
  python -m flake8 ${APP}
""")

This doesn't seem to be working as a get an error like :

No such property: imageNameParameter for class: genericJenkinsfile

The variable is declared like this at the beginning of the file

def APP = body.appName

I also tried various changes like using env.APP or using simple quotes around ${APP} but it didn't work either. Any thoughts ?

Upvotes: 2

Views: 1749

Answers (1)

Alex
Alex

Reputation: 440

I finally got it to work, for a reason that I can't really tell the triple string syntax uses only $APP to be called inside script:

Here's the solution:

sh(script: """
  python -m flake8 $APP
""")

Upvotes: 3

Related Questions