We require environment variables during the codebuild process. Codebuild allows you to setup environment variables in the advanced settings, which I've done.
Now when codebuild runs it doesn't seem to be passing these environment variables down.
I printed out process.env & here's what I got:
NAME: '037fga72',
[Container] 2017/02/08 01:55:03 NPM_CONFIG_LOGLEVEL: 'info',
[Container] 2017/02/08 01:55:03 PATH: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
[Container] 2017/02/08 01:55:03 PWD: '/usr/src/app',
[Container] 2017/02/08 01:55:03 SHLVL: '1',
[Container] 2017/02/08 01:55:03 HOME: '/root',
[Container] 2017/02/08 01:55:03 _: '/usr/local/bin/knex' } 'process.env variables...'
There are none of my envrionment variables.
I setup DB_PASS, DB_USER, DB_NAME, DB_HOST - None of these are printed out.
I tried creating a new codebuild & adding the environment variables but no luck.
Note that it's building a docker container & it fails when I try to connect to my postgres database because the environment variables aren't passed down (password, host, etc.)
Edit
In my Dockerfile, I'm running the following bash file:
#!/bin/bash
echo "running"
function mytest {
"$@"
local status=$?
if [ $status -ne 0 ]; then
knex migrate:rollback
echo "Rolling back knex migrate $1" >&2
exit 1
fi
return $status
}
mytest knex migrate:latest
What this is doing is running the knex migration (a js script) - If it fails we rollback the migration & exit the build.