Adding a new file during build

Hi everyone,

I’ve created this topic because I met a small problem using Circle 2.0 (in fact, “problem” is probably a large word), here’s the problem :

  • I need to create a JSON file during the build which contains my Google Cloud credentials, why? Well, my code needs it for the registration part and especially during the profile image upload (to a dedicated bucket).

I’ve tried to use the following code :

```yaml
    behat_core:
        docker:
            - image: circleci/php:7.1-node-browsers
            - image: redis
        steps:
            - checkout
            - run: sudo composer self-update
            - restore_cache:
                keys:
                    - composer-v1-{{ checksum "composer.json" }}
                    - composer-v1-
            - run: composer install -n --optimize-autoloader --classmap-authoritative
            - run: composer dump-autoload --optimize --classmap-authoritative
            - save_cache:
                key: composer-v1-{{ checksum "composer.json" }}
                paths:
                    - vendor
            - run: cp .env.dist .env
            - run: cp .env.behat.dist .env.behat
            - run: mkdir -p $CIRCLE_WORKING_DIRECTORY/config/credentials/google/bucket
            - run: echo $GCP_SERVICE_CREDENTIALS > $CIRCLE_WORKING_DIRECTORY/config/credentials/google/bucket/credentials.json
            - run: ./bin/console d:d:c --env=test
            - run: ./bin/console d:s:c --env=test
            - run: vendor/bin/behat --profile default
            - run: rm -rf var/data.db
```

The problem occurs when I try to “echo $GCP_SERVICE_CREDENTIALS > $CIRCLE_WORKING_DIRECTORY/config/credentials/google/bucket/credentials.json”, the build succeed but the file isn’t found and my tests fails, does anyone already met the problem ?

Thanks again for the help :slight_smile: