circleCI CLI - Cannot find a job named `build` to run in the `jobs:` section of your configuration file
Asked Answered
S

1

6

I'm using the circleCI CLI locally to test my .circleci/config.yml. This is what it looks like:

version: 2.1

jobs:
  test:
    docker:
      - image: circleci/node:4.8.2
    steps:
      - checkout
      - run: echo 'test step'

workflows:
  version: 2
  workflow:
    jobs:
      - test

This fails with the following error:

* 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:'

The 'hello world' workflow from the CLI docs works fine.

What am I missing here?

Sumerian answered 12/6, 2020 at 2:29 Comment(0)
S
7

In the same CircleCI CLI documentation mentioned above it has in the 'limitations' section:

The CLI tool does not provide support for running workflows. By nature, workflows leverage running jobs concurrently on multiple machines allowing you to achieve faster, more complex builds. Because the CLI is only running on your machine, it can only run single jobs (which make up parts of a workflow).

So I guess running workflows with orbs works (as in the 'hello world' example), but running workflows with your own jobs does not work with the CLI.

Testing Jobs Locally

If you're looking to test your config locally like I was, you can still execute your individual jobs locally. In the same documentation linked above, under the title 'Running a Job' when using config with version 2.1+ you can explicitly call one of your jobs like so:

circleci config process .circleci/config.yml > process.yml
circleci local execute -c process.yml --job JOB_NAME
Sumerian answered 12/6, 2020 at 2:29 Comment(3)
circleci local execute --job JOB_NAME worked for me.Primacy
perfect. just wanted to run tests. thank you @Sam!Ocrea
Updated link to docs: circleci.com/docs/…Mylohyoid

© 2022 - 2024 — McMap. All rights reserved.