Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not possible to avoid running on branches #415

Closed
goetzc opened this issue Jun 21, 2023 · 4 comments
Closed

Not possible to avoid running on branches #415

goetzc opened this issue Jun 21, 2023 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@goetzc
Copy link

goetzc commented Jun 21, 2023

Orb version: 4.12.5

What happened:

I want to avoid sending the notification on any branch trigger, including the default main branch. Only want to send notifications on workflows triggered by tags. So I have set branch_pattern and tag_pattern to different values without success.

branch_pattern: ''
# or
branch_pattern: ' '
# or
branch_pattern: '.'
# or
branch_pattern: '(?!)'

Or according to the README

A comma separated list of regex matchable branch or tag names. Notifications will only be sent if sent from a job from these branches/tags. By default ".+" will be used to match all branches/tags. Pattern must match the full string, no partial matches. Keep in mind that "branch_pattern" and "tag_pattern" are mutually exclusive.

Keep in mind that "branch_pattern" and "tag_pattern" are mutually exclusive.

but it seems outdated as it's not working with:

tag_pattern: '.+'

Without any pattern (or using the tag_pattern) it send the notification. On any of the branch_pattern above, it fails with the following error:

NO SLACK ALERT

Current reference "main" does not match any matching parameter
Current matching pattern: .

Exited with code exit status 1

CircleCI received exit code 1

image
image

Which makes the whole job fail.

Expected behavior:

I expect it to avoid sending the notification on any branch (including the default branch), and exiting cleanly with code 0, so the whole workflow/job passes.

Additional Information:

I'm not sure if I'm missing something, as the normal job filters (filters.tags.only, filters.branches.only or filters.branches.ignore) work normally. Is there some special pattern to avoid sending the notification on any branch?

Thanks

@goetzc goetzc added the bug Something isn't working label Jun 21, 2023
@EricRibeiro
Copy link
Contributor

EricRibeiro commented Oct 24, 2023

Hey @goetzc 👋

Thank you for bringing this to our notice, and sorry for not getting to it sooner. We have a proof-of-concept Slack orb wholly written in Go that will potentially solve this pattern-matching issue and some others.

Would you all be open to trying it and seeing if it solves your problem? We are looking for some early feedback. All you have to do is replace the orb version 4.12.5 in your config with dev:4463bcaee946c1e91829fdf6b3e0d1a7b6f12210:

version: 2.1

orbs:
-  slack: circleci/slack@4.12.5
+  slack: circleci/slack@dev:4463bcaee946c1e91829fdf6b3e0d1a7b6f12210

Please remember that dev:4463bcaee946c1e91829fdf6b3e0d1a7b6f12210 is a proof-of-concept, so it doesn't have feature parity with v4.12.5. As of the time of this writing, it doesn't support sub-shells expansions inside the templates:

{
    "blocks": [
        {
            "type": "section",
            "text": {
                "type": "mrkdwn",
                "text": "$(cat /tmp/msg)"
            }
        }
    ]
}

Thanks in advance, and let us know if it works for you! 🙇

Warning
dev:4463bcaee946c1e91829fdf6b3e0d1a7b6f12210 will be deleted after 90 days (January 22, 2024). Remember to roll back to a production version before the developer version gets deleted.

@marboledacci marboledacci self-assigned this Sep 16, 2024
@marboledacci
Copy link
Contributor

marboledacci commented Sep 16, 2024

@goetzc The development of the go version of the orb is on stand by for now. I'm checking this issue to see if there's a way you can implement it or if we need to do a change on the pattern logic.
For now, is it possible for your use case to use the normal job filters? More information here

@marboledacci
Copy link
Contributor

@goetzc You explained two problems, the pattern not working and the exit 1.
The first, you are using login shell. That's the cause of the exit 1 error. This shouldn't happen in the last version of the orb, as it is using a default shell configuration.
The second I'm fixing in PR #459, this should be fixed in our next release.

@marboledacci
Copy link
Contributor

Version 4.14.0 is solving the issue with tag pattern.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants