Commit Graph

44 Commits

Author SHA1 Message Date
Moritz Weichert
7b40007c37 feat: Enable discard-approval-on-plan for gitlab (#5388) 2025-03-10 22:08:22 +00:00
Luke Massa
c2c25aeef2 fix: Minor bug in determining teams for gitlab (#5294)
Signed-off-by: Luke Massa <lukefrederickmassa@gmail.com>
2025-02-02 22:32:50 -05:00
Pierre Guinoiseau
90b1b13b71 feat: Add support for GitLab groups (#4001)
Signed-off-by: Pierre Guinoiseau <pierre@guinoiseau.nz>
2025-01-25 18:39:37 +00:00
Rui Chen
e99a91b770 chore: migrate from xanzy/go-gitlab to gitlab-org/api/client-go (#5210)
Signed-off-by: Rui Chen <rui@chenrui.dev>
2024-12-31 13:24:53 -05:00
Simon Heather
8c6541f06f fix: Change GitLab UpdateStatus Function to get Pipeline from Commit rather than the Merge Request (#5033)
Signed-off-by: X-Guardian <simonheather99@gmail.com>
2024-11-11 22:41:18 +00:00
bakayolo
841f7b4277 feat: add ignore-vcs-status-names (github only) (#4978)
Signed-off-by: bakayolo <benjamin.apprederisse@gmail.com>
2024-11-04 22:04:13 +00:00
Andrew Fitzpatrick
ed03d35d59 fix: send pipelineID in gitlabs SetCommitStatus if the mr gets found, fallback to branch ref (#4785) 2024-08-07 23:54:24 -07:00
Christian Winther
633ca09fce fix: implement tests for gitlab client 409 Conflict handling (#4548) 2024-05-19 16:58:35 -04:00
Simon Heather
6824af5922 fix: Atlantis Apply Fails on GitLab v16.10 When the Merge Request Branch Needs Rebasing (#4402) 2024-04-05 15:08:58 +01:00
Simon Heather
67b5740053 feat: Refine The Atlantis VCS Logging Configuration (#4285)
* Refine VCS Logging

* Remove github/gitlab client logger

* Remove fmtLogSrc from instrumented_client and format

* Add staticcheck lint exception for NewGitHubClient

* Fix tests
2024-02-26 13:07:41 -05:00
Simon Heather
31802675da fix: Atlantis Does Not Consider the Plan Directory When Hiding Previous Plan Comments (#4012)
* Fix Hide Previous Plan Comments

* Update GitLab client tests

* Update GitLab client test

* Update github client test

* Add nolint: errcheck to test

* format github_client.go
2023-12-29 13:15:17 -05:00
Luke Massa
1035d9263a chore: Move gitlab client test data into testdata/ files (#4086)
* feat: Move gitlab client test data into testdata/ files

* Cleanup
2023-12-21 19:20:40 -05:00
Simon Heather
d1661dac4d fix: In Gitlab, if an Atlantis 'Apply' Pipeline Job fails, it cannot be Re-Applied on the Same Commit (#4007)
* Fix GitLab CI Must Pass

* Fix projectID

* nolint:staticcheck

* nolint:gosec

* Fix formatting

---------

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
Co-authored-by: Dylan Page <dylan.page@autodesk.com>
2023-12-12 02:45:58 +00:00
Gabriel Martinez
56e38b4151 chore(atlantis): fix linter errors (#3690)
* chore(atlantis): fix linter errors

* fix superfluous-else

* revert gitlab check

* ignore stub funcs on azuredevops_client

* remove fetch-depth

* remove fail_on_error

* fix plan_step_runner_test.go

* more lint fixes

---------

Co-authored-by: Dylan Page <dylan.page@autodesk.com>
2023-12-11 19:02:16 +00:00
Simon Heather
3056701c6b fix: Update GitLab Pipeline Type Detection to use Head Pipeline Property (#3887)
* Fix GitLab Mulitple Pipelines

* Add logger to tests and fix test ref

* Add retry to GetMergeRequest

* Update retries

---------

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2023-11-03 22:22:12 -04:00
Simon Heather
edc9bd9262 feat: Improve GitHub and GitLab Debug Logging (#3876)
* Improve GitHub and GitLab Debug Logging

* Fix formatting

* Fix g.client.Repositories.Get debug message

* Update gitlab_client_test with logger

---------

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2023-10-20 08:49:57 -07:00
Ghais Zaher
80ecc38273 feat: disable autoplan label (#3649)
* feat: disable autoplan label

* documentation

* revert unrelated change

* fix property

* gitlab and github

* dd more test

* small fixes

* add tests for github and gitlab clients

* fix: remove unrelated comments

* fmt

---------

Co-authored-by: PePe Amengual <jose.amengual@gmail.com>
2023-09-25 13:43:35 -04:00
MB
bcd917ffba fix(gitlab): Prevent considering non-head pipelines skipped by default (#3695)
By fixing nil pointer reference in 3428 we unveiled yet another bug now that the code is able to run further:

When an MR with no HeadPipeline exists its commits are set to skipped by default and thus create some mess when running "PullMergeable" (rendering the MR useless)

The bug was caught by the tests, however, in an attempt to make the build pass and unblock we create a patch to ignore that test.

In order to prevent further problems, this MR:

* Updates the test stack to run all plan/apply commands in the context
  of "HeadLess" Pipelines
* Fixes the default of skipped pipeline to false (as it is better to
  assume it is NOT skipped since that prevents the merge in most cases)
* Make all integratiion tests pass

References:

* Original MR: https://github.com/runatlantis/atlantis/pull/3428
* Tests Patch MR : https://github.com/runatlantis/atlantis/pull/3653
2023-08-23 17:07:38 -04:00
Ghais Zaher
25c6b43a63 fix: gitlab client failing test (#3653)
* fix: gitlab client failing test

* change HeadCommit to `67cb91d3f6198189f433c045154a885784ba6977`

* remove test case for now
2023-08-09 13:31:36 -04:00
MB
89a028ffd2 fix(gitlab): Prevent nil pointer dereference when HeadPipeline is empty (#3428)
In this particular example `mr.HeadPipeline.SHA` panics on a nil pointer dereference because HeadPipeline is empty.

This seems to be caused by the lack of permission to update the commit status.

```go
runtime.gopanic
        runtime/panic.go:1038
runtime.panicmem
        runtime/panic.go:221
runtime.sigpanic
        runtime/signal_unix.go:735
github.com/runatlantis/atlantis/server/events/vcs.(*GitlabClient).PullIsMergeable
        github.com/runatlantis/atlantis/server/events/vcs/gitlab_client.go:208
github.com/runatlantis/atlantis/server/events/vcs.(*ClientProxy).PullIsMergeable
        github.com/runatlantis/atlantis/server/events/vcs/proxy.go:72
github.com/runatlantis/atlantis/server/events/vcs.(*pullReqStatusFetcher).FetchPullStatus
        github.com/runatlantis/atlantis/server/events/vcs/pull_status_fetcher.go:28
github.com/runatlantis/atlantis/server/events.(*ApplyCommandRunner).Run
        github.com/runatlantis/atlantis/server/events/apply_command_runner.go:105
github.com/runatlantis/atlantis/server/events.(*DefaultCommandRunner).RunCommentCommand
        github.com/runatlantis/atlantis/server/events/command_runner.go:252
```

The least invasive solution is to simply use the commit-hash from pull and guess that the pipeline was "skipped" unless the HeadPipeline is there.

The outcome is:

When mr.HeadPipeline is present:
- use the commit hash and status from the HeadPipeline
When mr.HeadPipeline is NOT present:
- use the commit hash from pull request struct
- assume the pipeline was "skipped"

In cases where GitLab is configured to require a pipeline to pass, this results on a message saying the MR is not mergeable.

More info:
- https://github.com/runatlantis/atlantis/issues/1852
2023-08-04 13:00:47 -04:00
Simon Heather
556de93300 Gitlab Hide Previous Comments (#3476) 2023-06-13 21:03:36 -05:00
Isaac Wilson
8adb001aa6 fix(gitlab): Add backwards compatible mergability check (#3277)
* Add backwards compatibility for merability check in Gitlab client

* Cleanup
2023-03-30 19:31:56 -05:00
Joel Sleppy
3214b8c058 Poll Gitlab until changes are available (#3246)
Co-authored-by: Joel Sleppy <joel@sphinxdefense.com>
2023-03-20 20:46:35 +00:00
renovate[bot]
71738f15b6 fix(deps): update module github.com/xanzy/go-gitlab to v0.78.0 in go.mod (#2960)
* fix(deps): update module github.com/xanzy/go-gitlab to v0.78.0

* Deprecate MergeStatus for DetailedMergeStatus

* Update gitlab_client_test.go

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: nitrocode <7775707+nitrocode@users.noreply.github.com>
2023-01-15 20:47:28 -06:00
Michel Z. Santello
c800f706e4 fix(gitlab_client): prevent duplicate pipelines in gitlab merge requests (#2745)
* fix(gitlab_client): change CommitStatus update logic to prevent duplicated pipelines in MRs

* chore: refactor refTarget logic

* chore: fix tests

* chore: fix lint

* chore: remove nested if
2022-12-07 13:14:39 -08:00
Michel Z. Santello
479f2b7edb fix: prevent commit status update in incorrect MR (#2636)
* fix: prevent commit status in incorrect MR
  - closes https://github.com/runatlantis/atlantis/issues/2484

* chore: update test 'TestGitlabClient_UpdateStatus'
2022-11-04 09:22:55 -07:00
Michel Z. Santello
df0d58d29b fix: vcs-status-name hardcoded in PullIsMergeable function (#2312)
* feat: add userConfig.VCSStatusName to applyCommandRunner context

* fix: use vcsstatusname from context

* chore: normalize tests

* chore: update interface mock
2022-06-16 09:26:20 -07:00
Aiden Scandella
517358e612 Fix branch CI pipeline due to unchecked err in test (#2263)
Currently this is failing on PRs

```
server/events/vcs/gitlab_client_test.go:301:14: Error return value of `w.Write` is not checked (errcheck)
                                                w.Write([]byte(response))
```
2022-05-17 10:33:39 -07:00
Michel Z. Santello
02a1bb6507 [fix] ignore commit status for apply jobs (#2135) (#2137)
* fix: update commit status check logic to match the commit status name

* Update server/events/vcs/gitlab_client.go

chore: simplify ignored statuses logic

Co-authored-by: Emil 'Skeen' Madsen <sovende@gmail.com>

* feat(gitlab_client_test): add PullIsMergeable test case

Co-authored-by: Emil 'Skeen' Madsen <sovende@gmail.com>
2022-05-16 14:05:47 -07:00
rui
797b12de34 fix(gitlab): update tests (relates to #1971) (#2120)
Signed-off-by: Rui Chen <rui@chenrui.dev>
2022-03-07 12:06:56 -05:00
Eng Zer Jun
38cf7b0141 refactor: move from io/ioutil to io and os package (#1843)
The io/ioutil package has been deprecated as of Go 1.16, see
https://golang.org/doc/go1.16#ioutil. This commit replaces the existing
io/ioutil functions with their new definitions in io and os packages.

Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
2021-10-07 00:37:42 -04:00
Lucas C
cbef84fe09 feat: improving apply requirements for mergeable on Gitlab (#1675)
* Improving apply requirements for mergeable on Gitlab

* Fixing end of line

* Renaming variables

* Renaming variables

* Fixing variable assignment

* Fixing variable assignment
2021-08-02 13:34:11 -07:00
Istvan Tapaszto
632460b20b Delete source branch on merge (#1357)
Co-authored-by: Tapaszto, Istvan <istvan.tapaszto@msciintegration.onmicrosoft.com>
2021-04-22 09:54:18 -07:00
Nish Krishnan
7ac8106f8a Add structured logger (#54) (#1467)
This is two changes:

Replacing all usages of SimpleLogger with it's interface SimpleLogging which makes it easier to swap out loggers going forward
Nukes SimpleLogger in favor of StructuredLogger which allows us to better analyze logs in our log management system we choose.
2021-04-06 12:02:25 -07:00
Luke Kysow
f91cc27b68 Update go-gitlab 2020-08-06 15:30:20 -07:00
Florent Monbillard
1594fc2f83 GitLab's Merge Requests are using ! not # 2020-05-28 17:09:59 -04:00
David McPike
bc069d4b0c Add MarkdownPullLink function to VCS clients 2020-04-21 09:19:55 -05:00
Luke Kysow
3919f05548 Update to latest version of go-gitlab 2019-08-26 18:23:52 +02:00
Luke Kysow
8982a67b78 Run latest goimports 2019-03-30 20:22:49 -05:00
Luke Kysow
db1203bf0f Add better support for remote plan/apply.
Features:
- remote plans and applies will set a commit status with a link to the
Terraform Enterpise UI where the streaming output can be viewed.
- because remote plans don't support the -out flag, we diff the plan
output between plan and apply phases to ensure users are applying the
plan they expected

How:
We add a new capability to execute a terraform command while
concurrently reading its real-time output and performing actions
accordingly.
2019-02-27 17:26:00 -05:00
Luke Kysow
74e9bbb82b Add automerge feature.
Automerging merges pull requests automatically if all plans have been
successfully applied.

* Save status of PR's to BoltDB so after each apply, we can check if
there are pending plans.
* Add new feature where we delete successful plans *unless* all plans
have succeeded *if* automerge is enabled. This was requested by users
because when automerge is enabled, they want to enforce that a pull
request's changes have been fully applied. They asked that plans not be
allowed to be applied "piecemeal" and instead, all plans must be
generated successfully prior to allowing any plans to be applied.
2019-02-06 16:27:43 -06:00
Jocelyn Thode
2adaf4b24c Fix URL parsing not working when passing only a domain to GitlabHostname
Fixes https://github.com/runatlantis/atlantis/issues/377
2018-12-08 20:27:57 +01:00
Luke Kysow
ba04564e2a Disable markdown folding on gitlab < 11.1.
On startup, make a call to the /version endpoint of Gitlab to get which
version we're running. Then use that version to determine whether we
should use the markdown folding syntax where the code is expandable.
Versions of Gitlab < 11.1 don't support the "Common Mark" markdown
format.

Fixes https://github.com/runatlantis/atlantis/issues/315
2018-11-29 17:09:12 -06:00
Luke Kysow
1263ccb463 Move gitlab client setup into constructor. 2018-11-29 15:19:21 -06:00