Skip to content

Add `pages_path_prefix` job option

What does this MR do and why?

Add pages_path_prefix job option

As part of the introduction of the GitLab Pages Multiple Versions Support, we need to introduce pages_path_prefix as a pages job option on gitlab CI.

This is a iteration step towards the GitLab Pages Multiple Versions 👣. The main goal here is to save the pages_path_prefix on PagesDeployment records.

The PagesDeployment#path_prefix was added on !128930 (merged). This value will be used on Add versioned pages sites to pages internal API (#416494 - closed)

Related to: #416492 (closed)

Changelog: added

Screenshots or screen recordings

How to set up and validate locally

Numbered steps to set up and validate the change are strongly suggested.

  1. You need a license (https://about.gitlab.com/handbook/developer-onboarding/#working-on-gitlab-ee-developer-licenses)
  2. You need GitLab Runner (https://gitlab.com/gitlab-org/gitlab-development-kit/-/blob/main/doc/howto/runner.md?ref_type=heads)
  3. Enable pages_multiple_versions_setting feature flag
  4. Create a project using the html template (root/html for example`)
  5. Run the pipeline on that project (to ensure the pages is created)
  6. Navigate to Settings > Pages (http://gdk.test:3000/root/html/pages, for example)
    • Disable Force HTTPS (requires valid certificates)
    • Enable Use multiple versions
    • [optional] Click on the Access pages URL to see your GitLab Pages site 👀
  7. Edit your gitlab-ci.yml adding the pages_path_prefix to the pages job:
    pages:
      stage: deploy
      pages_path_prefix: 'mr$CI_MERGE_REQUEST_IID' # mr<iid>, like `mr123`
      script:
      - echo 'Nothing to do...'
      artifacts:
        paths:
        - public
      only:
      - master
  8. Run the pipeline again
  9. Go to rails console (bundle exec rails console) and check if the last PagesDeployment has the given prefix:
    [dev](main)> PagesDeployment.last.path_prefix
    => "mr2"
  10. Success! 🎉

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by Kassio Borges

Merge request reports