0

I have a pipeline where i have TARGETENVIRONMENT as QA and PROD.In the first step I am converting TARGETENVIRONMENT and storing that value in variable Ajob and Bjob.These values Ajob and Bjob are job names where i need to get the build number for processing further.

def Ajob = "ProjectBuild_ABD_${TARGET_PLATFORM.toUpperCase()}_fe"
def Bjob = "ProjectBuild_ABD_${TARGET_PLATFORM.toUpperCase()}_be"

In the next step I am storing the build numbers of these jobs.When i

def fe = sh returnStdout: true, script: '/usr/sfw/bin/wget -qO- http://fiesccet01.emea.nsn-net.net:9095/job/${Ajob}/lastBuild/buildNumber'
def be = sh returnStdout: true, script: '/usr/sfw/bin/wget -qO- http://fiesccet01.emea.nsn-net.net:9095/job/${Bjob}/lastBuild/buildNumber'

The script is not taking these values ${Ajob} and ${Bjob}.How to pass these variables in the script.

sudhir
  • 199
  • 2
  • 5
  • 16
  • try removing the def before each Ajob and Bjob declaration – mdo123 Apr 12 '18 at 03:10
  • 1
    maybe you also want to try the [`httpRequest`](https://jenkins.io/doc/pipeline/steps/http_request/#httprequest-perform-an-http-request-and-return-a-response-object) step. This will not solve your current problem in any way, but would look a bit nicer than calling `wget`. – StephenKing Apr 12 '18 at 04:47
  • 1
    Possible duplicate of [What's the difference of strings within single or double quotes in groovy?](https://stackoverflow.com/questions/6761498/whats-the-difference-of-strings-within-single-or-double-quotes-in-groovy) – mkobit Apr 12 '18 at 13:01

1 Answers1

1

Can you try this:

def fe = sh returnStdout: true, script: "/usr/sfw/bin/wget -qO- http://fiesccet01.emea.nsn-net.net:9095/job/${Ajob}/lastBuild/buildNumber"
def be = sh returnStdout: true, script: "/usr/sfw/bin/wget -qO- http://fiesccet01.emea.nsn-net.net:9095/job/${Bjob}/lastBuild/buildNumber"

The difference is that the strings are using double quotes, which apply string interpolation, i.e. replace variables, in contrast to single quotes, which don't.

StephenKing
  • 36,187
  • 11
  • 83
  • 112