Skip to content

Conversation

@leoalves100
Copy link

@leoalves100 leoalves100 commented Dec 18, 2025

what

Displays a comment in the MR when the branch destination does not match the pattern defined in repos.branch, preventing Atlantis commands from executing.

Currently, Atlantis interrupts execution without providing clear feedback to the user about the reason for the failure.

why

  • Improve user experience by providing clear and immediate feedback
  • Reduce confusion when a MR is blocked due to branch incompatibility
  • Facilitate quick diagnosis of the problem without needing to consult server logs
  • Increase understanding of branch restrictions configured in the repository

tests

  1. Set the repository's default branch to main or master.
  2. Open a new MR targeting a branch other than main or master.
  3. Atlantis starts execution but stops it after validating that the target branch does not match the default configured in repos.branch.
repos.yaml
# https://www.runatlantis.io/docs/server-side-repo-config.html
repos:
  - id: /.*/
    workflow: terragrunt
    branch: /^main$/
    apply_requirements:
      - approved
      - mergeable

workflows:
  terragrunt:
    plan:
      steps:
        - env:
            name: TERRAGRUNT_TFPATH
            command: 'echo $(which terraform)'
        - env:
            name: TF_IN_AUTOMATION
            value: "true"
        - run:
            command: terragrunt plan -input=false $(printf '%s' $COMMENT_ARGS | sed 's/,/ /g' | tr -d '\\') -no-color -out $PLANFILE
            output: hide
        - run: |
            terragrunt show $PLANFILE
    apply:
      steps:
        - env:
            name: TERRAGRUNT_TFPATH
            command: 'echo $(which terraform)'
        - env:
            name: TF_IN_AUTOMATION
            value: "true"
        - run: terragrunt apply -input=false $PLANFILE

references

@dosubot dosubot bot added feature New functionality/enhancement go Pull requests that update Go code labels Dec 18, 2025
@leoalves100 leoalves100 force-pushed the feat/add-erro-handling-in-unmatched-branch branch from c567d11 to 462a5d1 Compare December 18, 2025 17:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New functionality/enhancement go Pull requests that update Go code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant