在 CircleCI 命令中设置环境变量

Setting environment variable in CircleCI command

我想根据 CLI 命令的输出设置一个环境变量,我尝试了下面的但它不起作用

- run:
    name: Build web files
    command: API_URL="$(node utils/get-api-url.js)" && npm --prefix skynet/web run build

这是为什么?

我尝试了以下 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)

但是得到了

/bin/bash: API_URL:: command not found Exited with code 127

根据您的初始示例,试试这个:

- run:
  name: Build web files
  command: |
    API_URL=$(node utils/get-api-url.js)
    npm --prefix skynet/web run build

请记住,变量 API_URL 在此 CircleCI 步骤之外不可用。