circleci过滤器分支不起作用

时间:2018-07-11 16:05:16

标签: circleci-2.0 circleci-workflows

我是circleci的新手,我试图限制我的版本只能在特定分支上使用,我尝试了以下配置文件,但是当我包含过滤器部分时,出现以下错误:

Your config file has errors and may not run correctly:
2 schema violations found
  required key [jobs] not found
  required key [version] not found

带有过滤器的配置:

version: 2
jobs:
  provisioning_spark_installation_script:
    working_directory: ~/build_data
    docker:
      - image: circleci/python:3.6.6-stretch
    steps:
      - setup_remote_docker:
          docker_layer_caching: true
      - checkout
      - run: &install_awscli
               name: Install AWS CLI
               command: |
                 sudo pip3 install --upgrade awscli
      - run: &login_to_ecr
               name: Login to ECR
               command: aws ecr get-login --region us-east-1 | sed 's/-e none//g' | bash
workflows:
  version: 2
  deployments:
    jobs:
      - provisioning_spark_installation_script
        filters:
          branches:
            only: master

当我删除过滤器部分时,一切工作正常-但是没有过滤器,我知道如何使用shell进行解决,如果不是,那么它就不太优雅了。

有什么建议吗?

1 个答案:

答案 0 :(得分:1)

我只是在工作流名称之后缺少冒号,另外还有更多的过滤器缩进。

所以现在我有以下配置:

version: 2
jobs:
  provisioning_spark_installation_script:
    working_directory: ~/build_data
    docker:
      - image: circleci/python:3.6.6-stretch
    steps:
      - setup_remote_docker:
          docker_layer_caching: true
      - checkout
      - run: &install_awscli
               name: Install AWS CLI
               command: |
                 sudo pip3 install --upgrade awscli
      - run: &login_to_ecr
               name: Login to ECR
               command: aws ecr get-login --region us-east-1 | sed 's/-e none//g' | bash
workflows:
  version: 2
  deployments:
    jobs:
      - provisioning_spark_installation_script:
          filters:
            branches:
              only: master