CircleCI Doesn't find workflow in configuration

workflow
2.0
cci-20

#1

I am seeing this error:

Build-agent version 0.0.4761-f18e895 (2018-03-20T01:12:48+0000)
Configuration errors: 1 error occurred:

* Cannot find a job named `build` to run in the `jobs:` section of your configuration file.
If you expected a workflow to run, check your config contains a top-level key called 'workflows:'

I understand from the docs that I only have to have a job called build if I am NOT using workflows. I am using workflows, there is a workflows key.

What is wrong?

My full .circleci/config.yml:

Javascript Node CircleCI 2.0 configuration file

#
# Check https://circleci.com/docs/2.0/language-javascript/ for more details
#
version: 2
jobs:
  deploy:
    working_directory: ~/TryGhost/spirit
    docker:
      # CircleCI maintains a library of pre-built images
      # documented at https://circleci.com/docs/2.0/circleci-images/
      # This is closest to our current server version
      - image: circleci/node:6.13.0
    steps:
      - checkout

      # Make sure CircleCI can access our server
      - run: ssh-keyscan $PRD_SERVER >> ~/.ssh/known_hosts

      # Dependencies
      # Restore the dependency cache
      - restore_cache:
          keys:
          # This branch if available
          - v1-dep-{{ .Branch }}-
          # Default branch if not
          - v1-dep-master-
          # Any branch if there are none on the default branch - this should be unnecessary if you have your default branch configured correctly
          - v1-dep-
      # Install dependencies
      - run: yarn
        # Save dependency cache
      - save_cache:
          key: v1-dep-{{ .Branch }}-{{ epoch }}
          paths:
          - ~/.cache/yarn
          - ./node_modules

      # Deploy!
      - run: yarn deploy production

# Start here! This defines what actually happens and when
workflows:
  version: 2
  deploy:
    jobs:
      - deploy:
          # This context loads the user & ips for staging & production
          context: GhostOrg
          filters:
            # Only deploy on tags
            tags:
              only: /^v.*/

I’ve run into this error 4 or 5 times whilst setting up configs and each time I keep fixing it, seemingly, by deleting and re-adding whitespace and retrying.

Am I going mad?


#2

Do you have a “view whitespace characters” feature in your editor? YAML parsers tend to trip up spectacularly on tabs, I believe it must be spaces.


#3

I do - there are only spaces in the config

To follow up I have the exact same config working, but using this in workflows:

workflows:
  version: 2
  deploy:
    jobs:
      - deploy:
          context: GhostOrg
          filters:
            branches:
              only: master

That is - branch filter instead of tags and no comments. I tried updating that config to include the comments and it still worked. So its not the comments.

Next I tried switching the tag config shown above to using branches. On that project I’m not getting any new builds triggered at all now unless I manually post to the API using curl.

I’ve seen reports on here that some people don’t get new builds triggered if their workflows are misconfigured… but my config is now identical to the working one with the exception of the working directory name…


#4

To clarify.

I now have 2 identical builds on 2 very similar repos with identical config except the “workspace” path.

One does exactly what it should.
The other one fails with this error.


#5

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