CircleCI报告“无工作流"创建标记的发行版时 [英] CircleCI reports "No workflow" when creating a tagged release

查看:67
本文介绍了CircleCI报告“无工作流"创建标记的发行版时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想构建一个CircleCI工作流,该工作流仅在我在Github中创建带标记的发行版时才构建并推送到ECR.

I want to build a CircleCI workflow which builds and pushes to ECR only when I create a tagged release in Github.

我有以下CircleCI工作流程:

I have the following CircleCI workflow:

workflows:
  test-build-and-push-image:
    jobs:
      - get_python_dependencies
      - unit_tests:
          requires:
            - get_python_dependencies
      - aws-ecr/build-and-push-image:
          name: build-and-push-to-ecr
          repo: ${CIRCLE_PROJECT_REPONAME}
          tag: ${CIRCLE_SHA1}
          create-repo: true
          requires:
            - unit_tests
          filters:
            tags:
              only: /.*/
            branches:
              ignore: /.*/

据我了解, build-and-push-to-ecr 上的过滤器应该表示:

As I understand it, the filters on build-and-push-to-ecr are supposed to mean:

  • 针对任何标签运行此作业
  • 推送到任何分支机构时请勿执行此工作

但是当我创建一个带有标签的发行版时,我得到了:

But when I create a tagged release I get:

[![无工作流程] [1]] [1]

[![No workflow][1]][1]

为什么我的过滤器不起作用?[1]: https://i.stack.imgur.com/MQhlj.png

Why aren't my filters working? [1]: https://i.stack.imgur.com/MQhlj.png

推荐答案

A very close reading of the docs under Executing workflows for a git tag reveals a well-hidden detail:

如果一个作业需要任何其他作业(直接或间接),则必须使用正则表达式为这些作业指定标签过滤器.

if a job requires any other jobs (directly or indirectly), you must use regular expressions to specify tag filters for those jobs.

换句话说,工作流中的每个作业必须具有相同的过滤器,才能进行构建和推送作业.

In other words, every job in the workflow must have the same filters for the build and push job to happen.

我们可以使用& 锚点使事情变干:

We can keep things a bit DRYer using & anchors:

workflows:
  test-build-and-push-image:
    jobs:
      - get_python_dependencies:
          filters: &tagged
            # We only want to trigger this workflow on tags, not pushes to branches.
            branches:
              ignore: /.*/
            tags:
              # Trigger on every tag
              only: /.*/
      - unit_tests:
          requires:
            - get_python_dependencies
          <<: *tagged
      - aws-ecr/build-and-push-image:
          name: build-and-push-to-ecr
          repo: ${CIRCLE_PROJECT_REPONAME}
          tag: ${CIRCLE_SHA1}
          create-repo: true
          requires:
            - unit_tests
          <<: *tagged

这篇关于CircleCI报告“无工作流"创建标记的发行版时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆