0

I'm trying to construct a CI variable with an URL that points to the web access to GitLab CI artifacts; in order to use that variable for environments (MR previews). In short, for a project in group topgroup, subgroups gr1/gr2, project name myproject and gitlab pages deployed at domain pages.example.org, I want my variable to contain an URL like:

http://topgroup.pages.example.org/-/gr1/gr2/myproject/-/jobs/123456/artifacts/...[artifact path]...

The problematic part is the one between the two /-/ parts, the rest is either static or can be constructed using CI_JOB_ID and CI_PROJECT_ROOT_NAMESPACE. The middle part doesn't seem to be possible to reconstruct from the currently available CI variables (at least not without taking them to the shell and sedding some parts in and out). The closest I got is:

  • CI_PAGES_URL is ALMOST there, it gives the whole http://topgroup.pages.example.org/gr1/gr2/myproject, unfortunately without the /-/ required for artifacts
  • Constructing: $CI_SERVER_PROTOCOL://$CI_PROJECT_ROOT_NAMESPACE.$CI_PAGES_DOMAIN/-/$CI_PROJECT_PATH/-/jobs/$CI_JOB_ID/artifacts/... is almost there but unfortunately includes the topgroup in the CI_PROJECT_PATH, giving http://topgroup.pages.example.org/-/topgroup/gr1/gr2/myproject/-/jobs/123456/artifacts/...

Is there any way to construct this URL cleanly using simple means, without building it in the shell and re-exporting to gitlab variables?

exa
  • 859
  • 7
  • 27

0 Answers0