Pushing to develop branch does not trigger build

Hi,
I set up a simple PHP project on GitHub using the git-flow model. Currently, I have only two branches master and develop. I’m frequently pushing to develop and only want develop to be built currently, but the build on CircleCI is not triggered. (I can start a build using the API, though)

Here is my config that is mainly based on the default config, what am I doing wrong?

version: 2
jobs:
  build:
    docker:
      - image: circleci/php:7.2.9-apache-node-browsers
    branches:
      only:
        - develop
    working_directory: ~/repo
    steps:
      - checkout
      - restore_cache:
          keys:
          - v1-dependencies-{{ checksum "composer.json" }}
          - v1-dependencies-
      - run: composer install -n --prefer-dist
      - save_cache:
          paths:
            - ./vendor
          key: v1-dependencies-{{ checksum "composer.json" }}
      - run: ./vendor/bin/phpunit

Ping @FelicianoTech

Thanks for any help,
Matthias

From the docs:

A job that was not executed due to configured rules will show up in the list of jobs in UI, but will be marked as skipped.

Do you get this?

No, the last job in the list is 24h old. My last push to ‘develop’ happened an hour ago.

1 Like

Use the config below but make sure the file is available in both branches:

workflows:
  version: 2
  main:
    jobs:
      - build:
          filters:
            branches:
              only: develop

version: 2
  jobs:
    build:
      docker:
        - image: circleci/php:7.2.9-apache-node-browsers
      steps:
        - checkout
        - restore_cache:
            keys:
              - v1-dependencies-{{ checksum "composer.json" }}
              - v1-dependencies-
        - run: composer install -n --prefer-dist
        - save_cache:
            paths:
              - ./vendor
            key: v1-dependencies-{{ checksum "composer.json" }}
        - run: ./vendor/bin/phpunit

I was going to suggest using the workflows/branches device, @FelicianoTech. Does the job-level key not work correctly?

We’re about to find out. It should in that we have it listed in the Docs. If this works, then perhaps something is wrong with the job-level version and I’ll need to report that internally.

Personally, I also prefer the Workflows version since it’s easier to scale to larger configs in the future.

1 Like

Adjusted the config you posted, and now everything seems to work as expected :slight_smile: Thanks for your help!

version: 2
jobs:
  build:
    docker:
    - image: circleci/php:7.2.9-apache-node-browsers
    steps:
    - checkout
    - restore_cache:
        keys:
        - v1-dependencies-{{ checksum "composer.json" }}
        - v1-dependencies-
    - run: composer install -n --prefer-dist
    - save_cache:
        paths:
        - ./vendor
        key: v1-dependencies-{{ checksum "composer.json" }}
    - run: ./vendor/bin/phpunit

workflows:
  version: 2
  main:
    jobs:
    - build:
        filters:
          branches:
            only: develop
1 Like

I’ll look into why the way you were doing it didn’t work but otherwise I’m glad it works for you now.

Update:

FWIW, I tried out a simplified version of your original config. On a branch named 2.0-docker and a branch named develop and it worked as expected. Strange.

If you prefer using your original method over workflows, at this point I’d suggest contacting Support and sharing your original config and example build URLs that didn’t work as expected.

I was going to take a look at workflows sooner or later anyway, so I’m fine with this solution. Will probably extend the config step by step, so again thanks for the support!

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.