Reputation: 88197
I want to set an environment variable based on the output of a CLI command, I tried the below but it does not work
- run:
name: Build web files
command: API_URL="$(node utils/get-api-url.js)" && npm --prefix skynet/web run build
Why is that?
I tried the below following https://discuss.circleci.com/t/setting-environment-variables-with-a-command-fails/11034/4
- run:
name: Build web files
command: |
API_URL: $(node utils/get-api-url.js)
eval $(npm --prefix skynet/web run build)
But got
/bin/bash: API_URL:: command not found Exited with code 127
Upvotes: 2
Views: 827
Reputation: 4017
Based on your initial example, try this:
- run:
name: Build web files
command: |
API_URL=$(node utils/get-api-url.js)
npm --prefix skynet/web run build
Keep in mind, the variable API_URL
wouldn't be available outside of this CircleCI step.
Upvotes: 3