Creating config file testing

Hi there,

I am trying to setup my configuration so that it creates a new file during the continuous deployment which stores application specific variables (database connection/tokens etc). I prefer this approach than using environment variables, however, I receive and error that it cannot file the file. Below is my config.yml:

    version: 2
    jobs:
      build:
        working_directory: ~/project
        docker:
          - image: circleci/golang:1.12
        # Service container image available at `host: localhost`

          - image: circleci/postgres:9.6.2-alpine
            environment:
              POSTGRES_USER: postgres
              POSTGRES_PASS: dummypassword
              POSTGRES_HOST: localhost
              POSTGRES_DB: database
        steps:
          - checkout # check out source code to working directory
          
          # check if postgres is running
          - run:
              name: Waiting for Postgres to be ready
              command: |
                for i in `seq 1 10`;
                do
                  nc -z localhost 5432 && echo Success && exit 0
                  echo -n .
                  sleep 1
                done
                echo Failed waiting for Postgres && exit 1
          
          # setup config file
          - run:
              name: Config file setup
              working_directory: ~/project
              command : |
                  echo "ClientID: -" > config/conf.yml
                  echo "ClientSecret: -" >> config/conf.yml
                  echo "AccessToken: -" >> config/conf.yml
                  echo "RefreshToken: -" >> config/conf.yml
                  echo "Port: :8080" >> config/conf.yml
                  echo "dbUser: postgres" >> config/config.yml
                  echo "dbPass: dummypassword" >> config/config.yml
                  echo "dbHost: localhost" >> config/config.yml
                  echo "dbName: database" >> config/config.yml
                  echo "sslmode: disable" >> config/config.yml
                  echo "CookieUUID: -" >> config/config.yml
          
          # setup database
          - run:
              name: Database setup
              command: |
                bundle exec rake db:create
                bundle exec rake db:structure:load
          
          # run unit tests
          - run: go test ./...

And the error I receive when I push from my git repository:

#!/bin/bash -eo pipefail
echo "ClientID: -" > config/conf.yml
echo "ClientSecret: -" >> config/conf.yml
echo "AccessToken: -" >> config/conf.yml
echo "RefreshToken: -" >> config/conf.yml
echo "Port: :8080" >> config/conf.yml
echo "dbUser: postgres" >> config/config.yml
echo "dbPass: dummypassword" >> config/config.yml
echo "dbHost: localhost" >> config/config.yml
echo "dbName: database" >> config/config.yml
echo "sslmode: disable" >> config/config.yml
echo "CookieUUID: -" >> config/config.yml

/bin/bash: config/conf.yml: No such file or directory
Exited with code 1

I have tried without setting the working_directory in the ā€œConfig file setupā€ run task with no success. I also tried passing the absolute path as: echo "..." > ~/project/config/config.yml again with no success.

If you have any ideas please let me know. Thanks!

I am closing this. I have just discovered a typo in my path for the configuration fileā€¦ The code works as expected now.

1 Like

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