【问题标题】:Tag release not built with CircleCI标签发布不是用 CircleCI 构建的
【发布时间】:2018-11-11 23:58:23
【问题描述】:

我正在使用CircleCI构建一个项目,一切都运行良好,除了我的标签推送到github时没有构建:

我不明白为什么,我将整个配置简化为一个简约的配置文件,这是相同的逻辑:

version: 2

jobs:

  my_dummy_job_nightly:
    working_directory: ~/build
    docker:
      - image: docker:git
    steps:
      - checkout
      - setup_remote_docker:
          reusable: true
          exclusive: true

      - run:
          name: NIGHTLY BUILD
          command: |

            apk add --update py-pip
            python -m pip install --upgrade pip

  my_dummy_job_deploy:
    working_directory: ~/build
    docker:
      - image: docker:git
    steps:
      - checkout
      - setup_remote_docker:
          reusable: true
          exclusive: true

      - run:
          name: RELEASE BUILD
          command: |

            apk add --update py-pip
            python -m pip install --upgrade pip

###################################################################################
#                               CircleCI WORKFLOWS                                #
###################################################################################

workflows:
  version: 2
  build-and-deploy:
    jobs:

      ###################################################################################
      #                                  NIGHTLY BUILDS                                 #
      ###################################################################################

      - my_dummy_job_nightly:
          filters:
            tags:
              ignore: /.*/
            branches:
              only: master


      ###################################################################################
      #                                   TAGS BUILDS                                   #
      ###################################################################################

      - hold:
          type: approval
          filters:
            tags:
              only: /.*/
            branches:
              ignore: /.*/

      - my_dummy_job_deploy:
          requires:
            - hold
          filters:
            tags:
              only: /.*/
            branches:
              ignore: /.*/

我不明白为什么标签不构建......正则表达式应该让一切都通过......

【问题讨论】:

    标签: continuous-integration release continuous-deployment circleci


    【解决方案1】:

    TL;DR

    在 yaml 中,您忽略每个分支。删除以下部分。

    branches:
      ignore: /.*/
    

    您可能打算仅在显示标签时进行构建,但您忽略了所有分支。如果您想为每个带有标签的分支构建,请删除该行。如果你想为某个带有标签的分支(例如 dev)构建,那么添加branches: only: dev

    两个说明符之间的连接是AND,而不是OR。 CircleCI 论坛上有一个讨论添加功能以将其更改为OR

    【讨论】:

    • 我想执行不同的脚本,无论是分支构建还是标签构建。我会尝试你的提议,看看它是如何运作的
    • 如果我按照你的建议去做,那么每当我推送到分支时,所有作业都会启动。我希望我的部署构建仅在标记构建屏幕截图上运行:image.ibb.co/fvDRF8/image.png
    • 只能为 dev 分支构建。
    【解决方案2】:

    我终于找到了问题所在。与配置无关,CircleCI 界面不显示工作流界面中的标签构建,因此approval 操作阻塞了整个过程。

    要访问工作流并批准部署,您必须单击构建并单击工作流(见下文):

    一旦进入工作流程,就可以批准流程:

    我发现使构建出现的唯一解决方案是在构建过程中创建一个虚拟且无用的步骤,该步骤将在批准之前出现。

    version: 2
    
    jobs:
    
      init_tag_build:
        working_directory: ~/build
        docker:
          - image: docker:git
        steps:
          - checkout
          - setup_remote_docker:
              reusable: true
              exclusive: true
    
          - run:
              name: Launch Build OP
              command: |
                echo "start tag workflow"
    
      my_deploy_job:
        working_directory: ~/build
        docker:
          - image: docker:git
        steps:
          - checkout
          - setup_remote_docker:
              reusable: true
              exclusive: true
    
          - run:
              name: DEPLOY BUILD
              command: |
                echo "do the deploy work"
    
    workflows:
      version: 2
      build-and-deploy:
        jobs:
    
          - init_tag_build:
              filters:
                tags:
                  only: /.*/
                branches:
                  ignore: /.*/
    
          - hold:
              type: approval
              requires:
                - init_tag_build
              filters:
                tags:
                  only: /.*/
                branches:
                  ignore: /.*/
    
          - my_deploy_job:
              requires:
                - hold
              filters:
                tags:
                  only: /.*/
                branches:
                  ignore: /.*/
    

    【讨论】:

      猜你喜欢
      • 2019-01-27
      • 2020-07-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-06-26
      • 2022-10-13
      相关资源
      最近更新 更多