Escaping branch names to be triggered by a cron job

I am having trouble setting up a cron job that will run against a given branch. I am not sure if this is a yaml issue or a circle-ci issue, but in the example below development is run but release/2.0 and release/3.1 are not.

Here is the workflow from config.xml

  cypress_nightly:
    triggers:
      - schedule:
          cron: "0 4 * * *"
          filters:
            branches:
              only:
                - development
                - release/2.0
                - release/3.1
    jobs:
        - cypress

Through trial and error I’ve figured out that the issue is the forward slash in the branch name.

I’ve tried a number of different combinations of regex and string literal, but have had no luck. How can I properly specific the given release/x.y branch for this cron job?

That feels like a bug. Taking a look, will get back to you.

A couple of things:

  1. It needs to be a config.yml
  2. You are correct the slash is causing the problem but it is working as expected.
  3. Change release/2.0 to /release\/2\.0/ and release/3.1 to /release\./3\.1/ and you will get the results you want.
1 Like

Thanks @rohara!

  • Ah yes, it is config.yml, typo on my part.
  • Ok, I will escape both the / and . characters and give it another try. As a follow up, are those the only characters that need escaping?
1 Like

@rohara @drazisil

I am testing locally on a temp branch named feature/kburns_fix_cypress_cron2

config.yml workflow looks like:

workflows:
  version: 2
  build_and_test:
    jobs:
      - py_unittest:
          filters:
            tags:
              only: /.*/
              
  cron_five_mins:
    triggers:
      - schedule:
          cron: "0,5,10,15,20,25,30,35,40,45,50,55 * * * *"
          filters:
            branches:
              only:
                - /feature\/kburns_fix_cypress_cron2/
    jobs:
      - py_unittest:
          filters:
            tags:
              only: /.*/

As you can see I am explicitly escaping the / character in the branch name but not seeing the cron job get picked up. Any ideas?

Because you’re restricting it to tags, too.

@rohara - Removing the tag filtering has no effect for me. I’ve tried with this updated workflow and the job is still not being picked up (again, branch name is feature/kburns_fix_cypress_cron2)

workflows:
  version: 2
  build_and_test:
    jobs:
      - py_unittest
              
  cron_five_mins:
    triggers:
      - schedule:
          cron: "0,5,10,15,20,25,30,35,40,45,50,55 * * * *"
          filters:
            branches:
              only:
                - /feature\/kburns_fix_cypress_cron2/
    jobs:
      - py_unittest

What I said holds true. Let me show you on the same branch name you are using:

https://circleci.com/gh/ryanwohara/test-2.0/733
https://circleci.com/gh/ryanwohara/test-2.0/734
https://circleci.com/gh/ryanwohara/test-2.0/735

(Now I’ll push a new job to cancel the cron)

Hi @rohara

Thanks so much for stepping through this with me.

I see it is working for you and I decided to take a closer look at your config.yml. I noticed that mine is referencing version: 2.1 while yours has version: 2. I thought this this be a bug related to 2.1.

I have now copied your exact config.yml from here (https://github.com/ryanwohara/test-2.0/blob/7feeceea9d8bda91de57d666f659952d4ddf3316/circle.yml) and I am still unable to see the job getting run. Is there possibly some circle ci setting that needs to be adjusted on my end (2 vs 2.1)

Hi @drazisil This is marked as solved but I believe it may be a legit bug. I have used @rohara’s exact config.yml and am unable to trigger those cron jobs.

Can you open a ticket then https://support.circleci.com/hc/en-us/requests/new and share the number so we can take a look? Without that I can’t think of a reason why those jobs would not be triggering.

1 Like

Sure thing, I have created ticket # 47559. Thanks for your help!

2 Likes

@drazisil Ticket has been created but the response has been essentially the same as in this ticket. I have copy and pasted the exact same config.yml used by support and an seeing the same results (no . cron jobs queued)

I’ve been following it. Hard to find the cause when we can’t reproduce. Still working on it.

I’m having this same difficult trying to match release/.* as a regex.

My configuration contains:

        filters:
          branches:
            only: /release\/.*/

Also using configuration version 2.1.

Scratch that :slight_smile: . My issue was that the job with this filter was depending on another job that had a filter that wouldn’t also match /release\/.*/.