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

Atlantis server side repo config branch filter not working #1623

Open
vikiuvb opened this issue Jun 8, 2021 · 7 comments
Open

Atlantis server side repo config branch filter not working #1623

vikiuvb opened this issue Jun 8, 2021 · 7 comments
Labels

Comments

@vikiuvb
Copy link

vikiuvb commented Jun 8, 2021

I'm using the latest version of Atlantis - https://github.com/runatlantis/atlantis/releases/tag/v0.17.0. According to this pull request - #1383, adding a branch in the server config should match only the pull request whose base branch matches the branch pattern.

I'm using the following configuration.

repos:
  - id: <repoId>
    branch: local
    workflow: workflow-local

Atlantis is executing the terraform plan even if the base branch of the pull request is not local. My use case is similar to #982. I thought the latest release supporting branch filter should solve my use case. Am I missing something?

@minamijoyo
Copy link
Contributor

Looks duplicated #1539

@minamijoyo
Copy link
Contributor

@vikiuvb The bug #1539 was fixed in v0.17.3 via #1768.
Note that the branch keyword is a regex pattern. You should use branch: /^local$/

@sujeets-toast
Copy link

Here branch is destination for pullrequest
branch: /^pull_request_destination_banch_name$/

@jluque0101
Copy link

Hi @minamijoyo
I am trying to assign requirements when creating PR against specific branches (master|main|prod|prd).
First I target all repos and filter by branch (dev|develop) relaxing requirements to just diverged.
After that I define a new rule that targets all repositories again this time filtering for production branches so I can update apply_requirements to be mergeable as well however I am finding that when creating a PR against one of the development branches Atlantis doesn't trigger any job.

The reason why I am using /.*/ in both is due to the amount of repositories, ideally I'd like to avoid add repository settings one by one.

It seems the last match is the one taking precedence and therefore atlantis doesn't do anything for development branches.

  - id: /.*/
    branch: /^(dev|develop)$/
    workflow: multibranch
    allow_custom_workflows: true
    allowed_overrides: [ workflow ]
    plan_requirements: [ undiverged ]
    apply_requirements: [ undiverged ]
    import_requirements: [ undiverged ]
  - id: /.*/
    branch: /^(master|main|prod|prd)$/
    workflow: multibranch
    allow_custom_workflows: true
    allowed_overrides: [ workflow ]
    plan_requirements: [ undiverged ]
    apply_requirements: [ undiverged, mergeable ]
    import_requirements: [ undiverged ]

Is there a way to approach this currently? I am writing here because this issue seems to be somehow related to this issue but I'll be happy to open a new one if that's required, thanks!

@minamijoyo
Copy link
Contributor

Hi @jluque0101, I’m not sure it is a valid configuration to specify multiple any /.*/ matches for repository IDs. If so, it is unclear which should be prioritized.
https://www.runatlantis.io/docs/server-side-repo-config.html#repo

Regarding the branch attribute, the base branch restriction feature, a workflow will be triggered only if the specified base branch is used. Note that this is not a configuration selector like the id attribute. Atlantis does not have a way to determine which configuration to use based on the branch. So duplicated definitions seem to conflict with the requirements.

I guess what you need is a feature to customize settings based on both the repository ID and the base branch, isn’t it? If so, I recommend you open a new feature request.

@jluque0101
Copy link

Thanks @minamijoyo is clear now, I believe I misunderstood how branch filter works.

@dimisjim
Copy link
Contributor

dimisjim commented Feb 14, 2024

I've opened an issue which kinda relates to this here (which can maybe be closed?): #4245

The id repo & branch matcher behaviour wasn't clear for me: I had multiple same repo ids, but each for different branches, and didn't know whether the branch regex was incorrect, or something else (maybe the error sent could be improved too, coz I was just receiving: "command was run on a pull request which doesn't match base branches"))

@dosubot dosubot bot added the Stale label Oct 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants