我想要构建一个CircleCI工作流,它只在我创建一个带有标记的版本时才生成并推送到ECR。
我有以下CircleCI工作流:
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上的过滤器应该是指:
但是,当我创建一个标记的版本时,我得到:

为什么我的过滤器不能工作?
发布于 2020-12-18 10:15:21
仔细阅读为git标记执行工作流下的文档可以发现一个隐藏得很好的细节:
如果作业需要任何其他作业(直接或间接),则必须使用正则表达式为这些作业指定标记筛选器。
换句话说,工作流中的每个作业都必须具有相同的过滤器,才能实现生成和推送作业。
我们可以使用DRYer锚点保留一些&:
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
<<: *taggedhttps://stackoverflow.com/questions/65355175
复制相似问题