figbar
figbar

Reputation: 794

CircleCI Expected "jobRef"

I am new to CircleCI, and was attempting to setup a project. The initial setup and commit built the configuration file fine, however I needed to use environment variables, so I attempted to setup a context: https://circleci.com/docs/2.0/contexts/. I made a context with my environment variable and named it 'test-context'

Here is my config file: version: 2.1

orbs:
  python: circleci/[email protected]

workflows:
  sample:
    jobs:
      - build-and-test:
        context:
          - test-context

jobs:
  build-and-test:  
      - image: cimg/python:3.6
    parallelism: 4
    steps:
      - checkout
      - python/install-packages:
          pkg-manager: pip
     
          - run:
...

I get the following Linter error:

ERROR IN CONFIG FILE:
[#/workflows/sample] only 1 subschema matches out of 2
1. [#/workflows/sample/jobs/0] 0 subschemas matched instead of one
|   1. [#/workflows/sample/jobs/0] expected type: String, found: Mapping
|   |   SCHEMA:
|   |     type: string
|   |   INPUT:
|   |     build-and-test: null
|   |     context:
|   |     - test-context
|   2. [#/workflows/sample/jobs/0/context] expected type: Mapping, found: Sequence
|   |   SCHEMA:
|   |     type: object
|   |   INPUT:
|   |     - test-context

and - test-context is underlined with the error: Incorrect type. Expected "jobRef"

How can I use contexts to properly integrate environment variables with my project?

Upvotes: 0

Views: 657

Answers (1)

dempti
dempti

Reputation: 346

@figbar, the way you are writing it on the workflow has syntax issues. you should correct it as following.

orbs:
  python: circleci/[email protected]

workflows:
  sample:
    jobs:
      - build-and-test:
          context:
            - test-context

jobs:
  build-and-test:
    docker:
      - image: cimg/python:3.6
    parallelism: 4
    steps:
      - checkout
      - python/install-packages:
      - run:
...

You can get further information regarding the context on this documentation. CircleCI Context

Upvotes: 1

Related Questions