Ian Warburton
Ian Warburton

Reputation: 15676

Set env variable for NPM build step

Using terminal on my dev machine, I can do this...

SOME_VARIABLE=http://localhost:3000/ npm start

... and SOME_VARIABLE is accessible in the code using...

process.env.SOME_VARIABLE

Using the NPM build step in Azure DevOps, how do I set the same environment variable?

I can't add the variable in the "Command and arguments" text field because they're added after the generated call to npm.

Furthermore, if I copy the command that works on my dev machine and run it from a command line task, it won't accept the command format, I presume because it's Windows.

Upvotes: 3

Views: 2636

Answers (1)

4c74356b41
4c74356b41

Reputation: 72171

the existing answer is not what you would want, probably. what you want to do is go to build setting > variables and declare it there

https://learn.microsoft.com/en-us/azure/devops/pipelines/build/options?view=vsts&tabs=yaml#variables

Upvotes: 1

Related Questions