Another environment variable question: passing env variable to mongo setup

mongo
circle.yml

#1

So, I’ve been pouring over documentation and forums for a few days to do the test local env variables in a db setup for an authenticated mongodb setup.

My command is

circle build -e PASS='password'

At first I tried the following in my circle.yml file:

jobs:
  build:
    docker:
      # specify the version you desire here
      - image: circleci/node:10.2
      - image: circleci/mongo:4.0.0-rc0-ram
        environment:
          MONGO_INITDB_ROOT_USERNAME: login
          MONGO_INITDB_ROOT_PASSWORD: $PASS
        command: [mongod, --nojournal, --noprealloc, --smallfiles, --auth]

So, that didn’t work, but

MONGO_INITDB_ROOT_PASSWORD: password

does work, so the potential is there (maybe?).

Other variations that don’t work include:

MONGO_INITDB_ROOT_PASSWORD: ${PASS}
MONGO_INITDB_ROOT_PASSWORD: ${eval echo $PASS}
MONGO_INITDB_ROOT_PASSWORD: $(PASS)
MONGO_INITDB_ROOT_PASSWORD: $(eval echo $PASS)
MONGO_INITDB_ROOT_PASSWORD: <%= ENV['PASS'] %>

There are some other variations I’ve tried, but for mongo auth the MONGO_INITDB_ROOT_PASSWORD key in jobs/build/docker/image/environment seems to be necessary. I’ve also seen suggested passing in echo 'export PASS=$PASS' >> $BASH_ENV in a run step. I couldn’t get that working either.

Any thoughts?


#2

This topic was automatically closed 41 days after the last reply. New replies are no longer allowed.