Expand variables for `pages.publish` job property

What does this MR do and why?

Whenever a variable was passed to the Pages publish property, the deploy job would fail with the following error:

image

The failure occurred because the publish variable was not expanded correctly.

For example, in the following .gitlab-ci.yml configuration:

pages:
  artifacts:
    paths:
      - $CUSTOM_PATH
  publish: $CUSTOM_PATH
  variables: 
    CUSTOM_PATH: "test_path1"

The variable $CUSTOM_PATH, instead of being expanded to the value "test_path1", was treated as the string "CUSTOM_PATH", which prevented the validation from finding the correct directory.

In this merge request, I tried solving the issue by checking that the Pages' publish variables are expanded before this validation. These expanded variables are now saved to the build.pages property instead of being checked directly in build.options.

MR acceptance checklist

Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.

How to set up and validate locally

Click to expand the steps
  1. Create "Create from template" project at http://gdk.test:3000/projects/new
  2. Choose Pages/Plain HTML template
  3. After the project is created, update the .gitlab-ci.yml file with the following:
image: busybox

pages:
  stage: deploy
  script:
    - cp -r public test_path
  artifacts:
    paths:
      - $CUSTOM_PATH
  publish: $CUSTOM_PATH
  rules:
    - if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
  variables: 
    CUSTOM_PATH: "test_path"
  1. The deploy pipeline should now succeed and you can also check that everything works by going to Project > Deploy > Pages for additional info:

image

Original issue #500000 (closed)

Edited by Alisa Frunza

Merge request reports

Loading