Add new CI environment variable for creating links to artifacts

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

  • Close this issue

Problem to solve

Right now it's not possible to construct a generic URL for artifact files using CI environment variables for projects inside subgroups.

# Assume that the project path is `org/group/project`
environment:
  url: https://org.gitlab.io/-/group/project/-/jobs/<id>/artifacts/<path_to_file>

# With CI environment variables, we can make some of the URL generic, but not all of it:
environment:
  url: https://org.${CI_PAGES_DOMAIN}/-/group/${CI_PROJECT_NAME}/-/jobs/${CI_JOB_ID}/artifacts/coverage/report.html
  • CI_PROJECT_NAMESPACE cannot be used since <group>.gitlab.io only uses top level group, not including subgroups
  • CI_PROJECT_PATH cannot be used since the top level group is not includes in the path after /-/

Intended users

  • Sasha (Software Developer)
  • Presley (Product Designer)

Further details

Since "Private Project Support for Online View of HTML Artifacts" was released recently, it's now possible to link directly to an artifact for e.g. Code coverage report or similar. We use environments in .gitlab-ci.yml to create a visible link to a HTML page from the artifact in the job. It would be very helpful for us if we did not need to hard-code the path to the artifacts in our .gitlab-ci.yml.

Proposal

I suggest a new CI environment variable that would simplify retrieving the URL for an artifact file.

CI_ARTIFACTS_URL: https://<group>.gitlab.io/-/<project_path>/-/jobs/350748657/artifacts

# Possible alternatives for a more "basic" path? (names are very bad)
CI_JOBS_FILES_URL: https://<group>.gitlab.io/-/<project_path>/-/jobs
CI_PAGES_CI_FILES_URL: https://<group>.gitlab.io/-/<project_path>

Example usage:

image-regression:
  stage: test
  environment:
    name: qa/$CI_COMMIT_REF_NAME
    url: ${CI_ARTIFACTS_URL}/image-regression/index.html
  artifacts:
    when: always
    name: visual-regression-report
    paths:
      - ./image-regression/
    expire_in: 1 week
  script:
    - ...

Permissions and Security

Nothing new here. This would mostly be convenience to avoid hard-coding project paths.

Documentation

  • New variable(s) added to https://docs.gitlab.com/ee/ci/variables/predefined_variables.html

Testing

What does success look like, and how can we measure that?

Be able to create a link to an artifact file without hard-coding anything from CI_PROJECT_PATH.

What is the type of buyer?

Links / references

Edited Aug 26, 2025 by 🤖 GitLab Bot 🤖
Assignee Loading
Time tracking Loading