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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With