我是CircleCI的新手,并试图设置一个项目。最初的设置和提交很好地构建了配置文件,但是我需要使用环境变量,所以我尝试设置一个上下文:https://circleci.com/docs/2.0/contexts/。我用环境变量创建了一个上下文,并将其命名为"test-context">
这是我的配置文件:版本:2.1
orbs:
python: circleci/python@1.2
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:
...
我得到以下Linter错误:
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
和- test-context
下划线显示错误:Incorrect type. Expected "jobRef"
我如何使用上下文来正确集成环境变量与我的项目?
@figbar,你在工作流上写它的方式有语法问题。你应该按如下方式改正。
orbs:
python: circleci/python@1.2
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:
...
您可以在本文档中获得有关上下文的进一步信息。CircleCI上下文