【问题标题】:CircleCI ignores git tag filtersCircleCI 忽略 git 标签过滤器
【发布时间】:2019-11-10 20:49:10
【问题描述】:

我想测试每个提交(工作流程“测试”)。如果提交被标记并在某个分支上,则应触发部署(工作流程“test-n-deploy”)。 因此,我创建了以下工作流程:

workflows:
  version: 2
  test:
    jobs:
      - test-py36-yml
  test-n-deploy:
    jobs:
      - test-py36-yml:
          filters:
            tags:
              only: /[0-9]+(\.[0-9]+)*/
      - test-deploy-pypi:
          requires:
            - test-py36-yml
          filters:
            tags:
              only: /[0-9]+(\.[0-9]+)*/
            branches:
              only:
                - test_deployment_pypi
                - test_deployment_script

完整的脚本可以在这里找到:https://github.com/kipoi/kipoi/blob/test_deployment_pypi/.circleci/config.yml

我的问题: CircleCI 完全忽略标签过滤器。即使提交未标记,它也会运行整个 test-n-deploy 工作流。

我做错了什么?

【问题讨论】:

  • 你读过例如circleci.com/docs/2.0/workflows/…?您的配置似乎与您描述的不符。
  • @jonrsharpe 以哪种方式?如果您检查 CI 日志 (circleci.com/gh/kipoi/kipoi),您可以看到作业 #2914 正确运行“测试”工作流程,而作业 #2915 和 #2916 错误地为未标记的提交运行“test-n-deploy”。跨度>

标签: git continuous-integration circleci


【解决方案1】:

CircleCI 过滤器不结合两个过滤器,它就像一个“或”语句。 在您的情况下,即使您过滤了标签,test-deploy-pypi 也会在您过滤的分支之一中运行:test_deployment_pypitest_deployment_script

为了使其仅适用于标签,您必须忽略这些分支:

  filters:
    branches:
      ignore: /.*/
    tags:
      only: /v[0-9]+(\.[0-9]+)*/

请注意,我还将标签过滤器更改为在开头使用“v”,因为标签会自动添加它,除非您覆盖它。 如果您确实更改了默认的标签名称,请将其更改回您的正则表达式。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多