是否可以测试Travis中是否设置了加密的环境变量?

时间:2019-01-31 11:04:45

标签: environment-variables travis-ci

如果没有设置环境变量,我有必要跳过一个阶段。

如果将env var设置为纯文本,则可以使用,例如:

language: node_js
node_js:
- '10'
sudo: required
services:
- docker
- mongodb
script:
- npm run test
env:
  - DOCKER_PASS=TEST
jobs:
  include:
  - stage: Tests
    if: env(DOCKER_PASS) IS NOT blank
    name: Integration tests
    script: npm run test
  - stage: Mutation
    name: Mutation tests
    script: npm run test:mutation

但是如果我将环境变量更改为安全变量,例如:

travis encrypt DOCKER_PASS=test --add
language: node_js
node_js:
- '10'
sudo: required
services:
- docker
- mongodb
script:
- npm run test
jobs:
  include:
  - stage: Tests
    if: env(DOCKER_PASS) IS NOT blank
    name: Integration tests
    script: npm run test
  - stage: Mutation
    name: Mutation tests
    script: npm run test:mutation
env:
  global:
    secure: SECURE_VALUE

它不起作用。

将env()函数与安全的环境变量一起使用是否有限制?

0 个答案:

没有答案