For GitLab SaaS is preventing a merge a Netlify Pro feature (for failed Netlify build/deploy)

I have a few Netlify sites for which I want to use the same general pattern:

  1. Run a script which executes pre-commit tests on cloned git repository.
  2. Runs hugo and uses grep and friends to detect various Hugo failure modes
  3. Builds the site using Hugo
  4. Uses various post-build but pre-deploy Netlify plugins (html validation, lighthouse and link checking at the moment) to do a smoke test on the site
  5. Publishes a deploy preview

Only if all these steps succeed do I want a merge to be allowed for (e.g. https://gitlab.com/danielfdickinson/www-danielfdickinson) and, on merge to main, a production deploy to (for the same site: www.danielfdickinson.ca (and other domains aliases), which is Netlify site danielfdickinson.netlify.app).

Is this possible with Netlify and GitLab SaaS, and if so how (and does it require a paid plan for either or both of Netlify and GitLab)?

I did try to find this in the Netlify docs, but I’m not sure if the Netlify docs are not up to date with current GitLab (which I am not sure if this is even possible in current GitLab) or if the problem is not being on paid plan for either (at the moment, plan it change that, but ‘juggling’; my previous hosting contracts expire May and June so I’ll be able to move those dollars this way).

Any guidance you could give would be most welcome.

Has this been seen? In progress for an answer?

To confirm if I’ve understood you correctly, you want to block a merge request on GitLab from being merged till Netlify successfully publishes a deploy, correct?

If the above is correct, I don’t think any of the Git-specific features are different on different plans. But this feature doesn’t exist on any Git hosts, as far as I’m aware. For example, for GitHub, while we can show that the deploy failed:

there’s no way I’m aware that would block the Pull Request from being merged.

For GitLab, you’d have to add the checks yourself (as opposed to Netlify doing it automatically for GitHub). This is done in: https://app.netlify.com/sites/<subdomain>/settings/deploys#deploy-notifications

With that being said, the only way I can think of is to manually approve Merge Requests. On GitLab, it’s possible to automate it using their API: Merge request approvals API | GitLab, so you can trigger a webhook from Deploy Notifications in Netlify and that webhook can approve the MR for you.

1 Like

FYI: On GitHub those deploy statuses can be used by setting up ‘branch protection’ and including successful statuses from Netlify in the set of statuses required before a merge is allowed to proceed.

I am not aware of a way to do the same thing on GitLab SaaS, but the approval and API solution sounds like it will achieve what I want.

With current GitLab (as of a few moments ago) it is working. I am not sure what changed, but I did have to re-enter my PAT for each notification individually (the previous PAT had expired and there were not even comments being added. (Previously the comments were correctly added).