Enable environments in GitLab

Created on 16 July 2025, 27 days ago

Problem/Motivation

Whilst it is possible to deploy to an environment with GitLab CI, the UI elements that display it on a Merge Request or the dedicated environments page have been disabled.
https://docs.gitlab.com/ci/environments/#environment-url

On the drupal.org instance, when deploying an environment the job will show as it having succeeded and generate a link to a 404ed page of the format https://git.drupalcode.org/project/project-name/-/environments/1234

In the case of Pages, you can see some of the deployments under https://git.drupalcode.org/project/project-name/pages, but this obviously doesn't work for other scenarios e.g. linking to a merge request or test environment, and it would be preferable to have it linked directly from the Merge Request.

Steps to reproduce

in .gitlab-ci.yml

pages-mr:
  image: node:22
  stage: deploy
  needs: []
  rules:
    - if: $CI_PIPELINE_SOURCE == "merge_request_event"
  script:
    - npm ci
    - npm run build
  pages:
    publish: docs/
    path_prefix: "mr-$CI_MERGE_REQUEST_IID"
    expire_in: 1 month
  environment:
    name: pages/mr-$CI_MERGE_REQUEST_IID
    url: $CI_PAGES_URL
    on_stop: stop-pages-mr

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Component

GitLab

Created by

🇬🇧United Kingdom justafish London, UK

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @justafish
  • 🇺🇸United States drumm NY, US

    As the Drupal Association, we don’t really want to be in the business of being integrated into individual site deployments. That’s not something we’re prepared to provide support for, or guarantee availability, especially for free. As far as I can tell, the primary use of environments is the continuous deployment part of CI/CD.

    Enabling for test environments on clusters which the Drupal Association does not manage or provide could be interesting. I’d like a bit more context on the use case here.

    GitLab’s UI doesn’t have a way to add explanations around supported uses of environments, so we’d have to weigh this against the inevitability that it might be used in ways we don’t really want to support.

  • 🇬🇧United Kingdom justafish London, UK

    we don’t really want to be in the business of being integrated into individual site deployments. That’s not something we’re prepared to provide support for, or guarantee availability

    Absolutely! This is just enabling the exposure of links to environments in the UI that you can already deploy to with GitLab CI - the expectation isn't that the DA would be hosting environments, it's just a nice way to link to external ones. You can already see it partially working on this job here with the "This job is deployed to" banner: https://git.drupalcode.org/project/experience_builder/-/jobs/5936806

    A couple of things we're using it for in Experience Builder which would be useful to surface on the MR itself:
    1. Pages deployments, which are already surfaced here https://git.drupalcode.org/project/experience_builder/pages
    2. Showing test result reports which are richer than JUnit, for example: https://project.pages.drupalcode.org/-/experience_builder/-/jobs/5906499...
    3. It'd also be useful to display Tugboat environment links if we ever set that up again.

  • 🇬🇧United Kingdom justafish London, UK
  • 🇺🇸United States drumm NY, US

    Right now we’re thinking we want to stay with the current behavior, since we do not want to encourage deployments from git.drupalcode.org. We have seen what looks like people trying to deploy production sites using the community infrastructure a few times before.

    If I understand correctly, for experience builder, it sounds like things are working, but some links and quality of life features are not accessible.

Production build 0.71.5 2024