Open tiagomeireles opened 4 months ago
This is an ancient, foolish decision to adopt this MR, resulting in us living on v0.19.2.
@shurkus What exactly makes you live on v0.19.2? PR that you referenced added an optional, disabled by default, feature for GitHub only.
wrong here is this one #2053, corrected
So this is completely broken for us on latest. The atlantis/apply top level job only ever shows up after we have applied one of the projects in a repo. But it doesn't prevent merging before anything has been applied.
To be clear I am not sure it has ever worked on gitlab or if it did I didn't notice when it broke and it's been burning us the last while
Any updates? Our developers sometimes merge MRs before applying the terraform content because the pipeline succeeds even if there are changes ti be applied. We would love to have back the way to block this behavior!
Maybe remove the right to merge to all developers ? (only Atlantisbot and Maintainer allowed to merge)
we have it already limited, nevertheless this is something that should be blocked by a pending status pipeline in case some changes are detected
Any news?
Can be fixed by adding to plan_command_runner.go#L117
// At this point we are sure Atlantis has work to do, so set commit status to pending
if err := p.commitStatusUpdater.UpdateCombined(ctx.Log, ctx.Pull.BaseRepo, ctx.Pull, models.PendingCommitStatus, command.Plan); err != nil {
ctx.Log.Warn("unable to update plan commit status: %s", err)
}
if err := p.commitStatusUpdater.UpdateCombinedCount(ctx.Log, ctx.Pull.BaseRepo, ctx.Pull, models.PendingCommitStatus, command.Apply, 0, len(projectCmds)); err != nil {
ctx.Log.Warn("unable to update apply commit status: %s", err)
}
but looks like it can break Github :crying_cat_face:
I think this thread can be considered closed after the last version: v0.28.3
Yep, tested and work fine
Community Note
Overview of the Issue
Currently, I am able to merge a merge request in Gitlab before
atlantis apply
is ran. I want the ability to prevent merge requests from being able to be merged withoutatlantis apply
completing successfully.There has been previous attempts for example https://github.com/runatlantis/atlantis/pull/2053 introduced this behavior but was rolled back because of workflows that are dependent on all CI jobs being completed.
https://github.com/runatlantis/atlantis/pull/3378 (unintentionally?) introduced this behavior again, then was reverted in https://github.com/runatlantis/atlantis/pull/3747.
https://github.com/runatlantis/atlantis/pull/2436#issuecomment-1211252243 describes the behavior I expect using Github.
Using 0.27.2, when I open a merge request that creates new resources. (Iām using
resource "terraform_data" "example" {}
) Atlantis autoplans, creating an external stage with the following jobs.I expect there to be a pending
atlantis/apply
job to prevent the merge request from being merged as my repo require CI to be passing. If I revert https://github.com/runatlantis/atlantis/pull/3747/files#diff-6583ec7260b28e573c74e18e783ee24ba8dce7d0a2e6929c105cc7e74d3d9c6fL318-R319 from https://github.com/runatlantis/atlantis/pull/3747, I get the behavior I expect.Then after a successful
atlantis apply
, theatlantis/apply
job andatlantis/apply: <project>
succeed and I can merge the merge request.Are there other Gitlab users who have similar requirements? Am I missing something(e.g a flag?) that makes this possible?
I'm open to other methods of preventing merging without successful
atlantis apply
's. Happy to contribute any patches that support this workflow.Reproduction Steps
Logs
Environment details
Atlantis server-side config file:
Repo
atlantis.yaml
file: N/AAdditional Context