1

I am using jenkins for building my project periodically. While creating the jenkins parameterised job i am passing few paramenters like credentials and other things. Now I want values of these parameters in my project so that I could run it. How can I achieve this?

Here is the screenshot of the jenkins enter image description here

So basically i want to access the values of buildEnv and buildModule in my codes. The project is an express js application.

Alasdair
  • 298,606
  • 55
  • 578
  • 516
Siddharth Sinha
  • 578
  • 2
  • 15
  • 35

1 Answers1

1

They're passed in as environment variables so they're accessed like any other: Read environment variables in Node.js

Community
  • 1
  • 1
chedabob
  • 5,835
  • 2
  • 24
  • 44
  • I did what you asked me, but still i am getting "undefined" if i am doing console.log(process.env.variable). If i explicitly declare the environment variable in my bash profile and then read it, then i am getting the value.Any idea what is wrong?? – Siddharth Sinha Jan 07 '16 at 07:12
  • How are you launching your node.js script? – chedabob Jan 07 '16 at 08:55
  • I am using node app.js. That's all – Siddharth Sinha Jan 07 '16 at 09:02
  • Yes but how are you running it from Jenkins? Are you using a `Batch Task` ? – chedabob Jan 07 '16 at 09:04
  • I am making use of curl command to open a specific url which will start the functioning of my application. I am putting this command in the jenkins shell window. – Siddharth Sinha Jan 07 '16 at 09:22
  • In that case you should be able to access them in your Curl command like other environment variables and pass them to your server as part of the request http://stackoverflow.com/questions/31964031/using-environment-variables-in-curl-command-unix – chedabob Jan 07 '16 at 09:44