我正在尝试使用我的circleci环境变量在Circleci配置文件中生成一个env.ts文件。我尝试了下面的代码:
steps:
- run:
name: Setup Environment Variables
command:
echo "export const env = {
jwtSecret: ${jwtSecret},
gqlUrl: ${gqlUrl},
engineAPIToken: ${engineAPIToken},
mongodb: ${mongodb},
mandrill: ${mandrill},
gcpKeyFilename: ${gcpKeyFilename},
demo: ${demo},
nats: ${NATS},
usernats: ${usernats},
passnats: ${passnats} };" | base64 --wrap=0 > dist/env.ts
但是它输出:
#!/bin/sh -eo pipefail
# Unable to parse YAML
# mapping values are not allowed here
# in 'string', line 34, column 24:
# jwtSecret: ${jwtSecret},
# ^
#
# -------
# Warning: This configuration was auto-generated to show you the message above.
# Don't rerun this job. Rerunning will have no effect.
false
Exited with code 1
答案 0 :(得分:0)
我忘了在command: |
之后写一个管道
steps:
- run:
name: Setup Environment Variables
command: |
echo "export const env = {
jwtSecret: '${jwtSecret}',
gqlUrl: '${gqlUrl}',
engineAPIToken: '${engineAPIToken}',
mongodb: '${mongodb}',
mandrill: '${mandrill}',
gcpKeyFilename: '${gcpKeyFilename}',
demo: ${demo}, // it's a boolean
nats: '${NATS}',
usernats: '${usernats}',
passnats: '${passnats}'
};" > dist/env.ts
注意:同样,我也忘记在变量周围添加“”。