9

I am using CircleCI to build a project, everything is running fine, except that my tags are not built when pushed to github:

I don't understand why, I have reduced my whole configuration to a minimalistic config file, it's the same logic:

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

I don't understand why the tags don't build ... The regex should let everything through...

Jonathan DEKHTIAR
  • 3,456
  • 1
  • 21
  • 42

2 Answers2

2

I have finally found the issue. Nothing to do with the configuration, CircleCI interface do not show tag build in the Workflows Interface and thus the approval operation block the whole process.

To access the workflow and approve the deployment, you have to click on the build and click on the workflow (see below):

enter image description here

Once on the workflow, it is possible to approve the process:

enter image description here

The only solution I have found to make the build appear is to create a dummy and useless step in the build process that will appear before the 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: /.*/
Jonathan DEKHTIAR
  • 3,456
  • 1
  • 21
  • 42
1

TL;DR

In the yaml you ignore every branch. Remove the following part.

branches:
  ignore: /.*/

You probably meant to build only if tags are shown, but you ignored all the branches. If you want to build for every branch with tags remove the line. If you want to build for some branch (e.g. dev) with tags then add branches: only: dev.

The connection between the two specifier is AND instead of OR. There is a discussion on CircleCI forum to add feature to change it to OR.

androbin
  • 1,622
  • 14
  • 31