标签版本不是用CircleCI构建的

时间:2018-06-01 19:56:25

标签: continuous-integration release continuous-deployment circleci

我正在使用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: /.*/

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

2 个答案:

答案 0 :(得分:2)

我终于找到了这个问题。与配置无关,CircleCI接口不会在工作流界面中显示标记构建,因此approval操作会阻止整个过程。

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

enter image description here

进入工作流程后,可以批准该流程:

enter image description here

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

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: /.*/

答案 1 :(得分:1)

TL; DR

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

<!DOCTYPE html>
<html>

<head>
  <link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css" integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ==" crossorigin="" />
  <script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet-src.js" integrity="sha512-IkGU/uDhB9u9F8k+2OsA6XXoowIhOuQL1NTgNZHY1nkURnqEGlDZq3GsfmdJdKFe1k1zOc6YU2K7qY+hF9AodA==" crossorigin=""></script>
  <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
  <style></style>
</head>

<body>
  <div id="mapid" style="height: 180px"></div>
 	  <div id="layercontrol">
    <input id="layercontrol2" type="checkbox" /> Topo Map
    <br />
    <!--input id="layercontrol3" type="checkbox" /> Satellite
    <br /-->
  </div>
</body>

</html>

您可能只想在显示标记时进行构建,但忽略了所有分支。如果要为带有标记的每个分支构建,请删除该行。如果您想为带有标签的某个分支(例如dev)构建,请添加branches: ignore: /.*/

两个说明符之间的连接是branches: only: dev而不是AND。在CircleCI论坛上讨论了添加功能以将其更改为OR