Hi.
I have a problem with my CircleCi during deploy my project. When a build finish with success. CircleCi don`t deploy my code on vps. But when I click Return job with ssh I see a message:
Your config file has errors and may not run correctly: jobs: deploy: -prodextraneous key [workflows] is not permitted
It`s my code:
version: 2
jobs:
build:
working_directory: ~/micropost
docker:
- image: circleci/php:7.2.0-apache-stretch-node-browsers
environment:
APP_ENV: test
DATABASE_URL: mysql://root:root@127.0.0.1/micro-post
MAILER_FROM: micro@micropost.com
MAILER_URL: null://localhost
- image: circleci/mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: ‘root’
MYSQL_DATABASE: micro-post
steps:
- checkout
- run:
name: Install PHP MySQL
command: sudo docker-php-ext-install pdo_mysql
- run:
name: Wait for MySQL
command: dockerize -wait tcp://127.0.0.1:3306 -timeout 120s
- run:
name: Composer
command: sudo composer self-update
- run:
name: Composer install
command: composer install -n --prefer-dist
- run:
name: Run migrations
command: php bin/console doctrine:schema:update --force
deploy:
working_directory: ~/micropost
docker:
- image: circleci/php:7.2.0-apache-stretch-node-browsers
steps:
- checkout
- run:
name: Composer install
command: composer install -n --prefer-dist
- run:
name: Clear cache
command: php bin/console cache:clear --env=prod --no-interaction
- run:
name: Yarn install
command: yarn install && yarn run encore production
- run:
name: Add droplet
command: ssh-keyscan -H $DROPLET_IP >> ~/.ssh/know_hosts
- run:
name: Pre-deploy
command: ssh -T $DROPLET_USER:$DROPLET_IP < bin/deploy/pre_deploy.sh
- run:
name: Deploy code
command: rsync -vzcrSLhp --exclude '.env' --delete ~/micropost/ $DROPLET_USER@$DROPLET_IP:/var/www/micropost_current
- run:
name: Post deploy
command: ssh -T $DROPLET_USER:$DROPLET_IP < bin/deploy/deploy.sh
workflows:
version: 2
build-and-deploy:
jobs:
- build
- deploy:
requires:
-build
filters:
branches:
only: master
thank you in advance for your help.
ScottW
December 19, 2019, 2:41pm
2
It looks like there is a typo in the workflow definition. There should be a space between the “-” and build. See the below example.
workflows:
version: 2
build-and-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master
Additionally, you can use the CircleCI CLI to validate configurations with the below command.
circleci config validate path/to/config
More information is available on this doc: https://circleci.com/docs/2.0/local-cli/#validate-a-circleci-config
Thenk you for help.I change my code and after refresh web CircleCi.I see build and deploy. But I have a message not_running build and blocked deploy. What is going on ?
My new code:
version: 2
jobs:
build:
working_directory: ~/micropost
docker:
- image: circleci/php:7.2.0-apache-stretch-node-browsers
environment:
APP_ENV: test
DATABASE_URL: mysql://root:root@127.0.0.1/micro-post
MAILER_FROM: micro@micropost.com
MAILER_URL: null://localhost
- image: circleci/mysql:5.7
environment:
MYSQL_ROOT_PASSWORD: 'root'
MYSQL_DATABASE: micro-post
steps:
- checkout
- run:
name: Install PHP MySQL
command: sudo docker-php-ext-install pdo_mysql
- run:
name: Wait for MySQL
command: dockerize -wait tcp://127.0.0.1:3306 -timeout 120s
- run:
name: Composer
command: sudo composer self-update
- run:
name: Composer install
command: composer install -n --prefer-dist
- run:
name: Run migrations
command: php bin/console doctrine:schema:update --force
deploy:
working_directory: ~/micropost
docker:
- image: circleci/php:7.2.0-apache-stretch-node-browsers
steps:
- checkout
- run:
name: Composer install
command: composer install -n --prefer-dist
- run:
name: Clear cache
command: php bin/console cache:clear --env=prod --no-interaction
- run:
name: Yarn install
command: yarn install && yarn run encore production
- run:
name: Add droplet
command: ssh-keyscan -H $DROPLET_IP >> ~/.ssh/know_hosts
- run:
name: Pre-deploy
command: ssh -T $DROPLET_USER:$DROPLET_IP < bin/deploy/pre_deploy.sh
- run:
name: Deploy code
command: rsync -vzcrSLhp --exclude '.env' --delete ~/micropost/ $DROPLET_USER@$DROPLET_IP:/var/www/micropost_current
- run:
name: Post deploy
command: ssh -T $DROPLET_USER:$DROPLET_IP < bin/deploy/deploy.sh
workflows:
version: 2
build-and-deploy:
jobs:
- build
- deploy:
requires:
- build
filters:
branches:
only: master