Monday 5 June 2017

circleci - cannot read env variables defined inside script

I write a script for setting env variables.

export DB_HOST='127.0.0.1'
export DB_USER='ubuntu'
export DB_PWD=''
export DB_NAME='circle_test'

My circle.yml look like this

machine:
  timezone: Asia/Taipei
  services:
    - mysql

dependencies:
  pre:
    - sudo apt-get update
    - nvm install 7.9 && npm install

test:
  pre:
    - source ./config/test_config.sh
    - sh ./config/test_config.sh
    - pwd
    - printenv
  override:
    - nvm use 7.9 && npm test

My nodejs application cannot read the env variables and I didn't saw in the printenv also.

I don't want to write env variables directly into circle.yml file because I would like to have prod_config.shdev_config.sh to dynamically change.

How can I do that ?



via 鄭元傑

No comments:

Post a Comment