GitLab页面可以用于mkdocs项目上的审阅应用程序吗? [英] Can GitLab pages be used for review apps on a mkdocs project?

查看:169
本文介绍了GitLab页面可以用于mkdocs项目上的审阅应用程序吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此答案 @joki 上一个问题暗示可以通过为可浏览的工件提供公共URL,将GitLab存储库中的每个活动分支部署到动态环境.

This answer by @joki to a previous question suggests that it is possible to deploy each active branch in a GitLab repo to a dynamic environment, by giving browsable artifacts a public URL.

通过 mkdocs材料项目进行尝试,我发现了两个问题.

Trying this out with a mkdocs material project, I've found two issues.

首先,如果GitLab存储库在组或子组中,则.gitlab-ci.yml文件中的URL应该更像这样:

Firstly, if the GitLab repo is within a group or a subgroup the URLs in the .gitlab-ci.yml file needs to be something more like this:

    environment:
        name: review/$CI_COMMIT_REF_NAME
        url: "$CI_PAGES_URL/-/jobs/$CI_JOB_ID/artifacts/public/index.html"
        auto_stop_in: 1 week
    variables:
        PUBLIC_URL: "$CI_PAGES_URL/-/jobs/$CI_JOB_ID/artifacts/public/"

其次,网站内的相对链接无法正常工作,从而导致许多404错误以及样式文件之类的东西丢失.可能上述网址不正确,或者mkdocs.yml中的site_url需要更改为以下内容:

Secondly, relative links within the site don't work well, leading to a lot of 404 errors, and the loss of things like style files. Possibly the URLs above are not right, or maybe the site_url in mkdocs.yml needs changing to something like:

site_url: !!python/object/apply:os.getenv ["CI_ENVIRONMENT_URL"]

但是,这些都不对我有用.

however, neither of these quite worked for me.

具有非常小的部署和审阅应用程序的最小MR可以是

A minimal MR with a very small deployment and review app can be found here.

有人对mkdocs评论应用有有效的秘诀吗?

Does anyone have a working recipe for mkdocs review apps?

推荐答案

您可以在管道中build步骤的»浏览«按钮中看到所需的URL.

You can see the URL you need in the »Browse« button of the build step in your pipeline.

这行吗?

develop:
    artifacts:
        paths:
          - public

    environment:
        name: Develop
        url: "https://$CI_PROJECT_NAMESPACE.gitlab.io/-/snim2-test-subgroup/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public/index.html"

    script: |
        # whatever

    stage: deploy

    variables:
        PUBLIC_URL: "/-/snim2-test-subgroup/$CI_PROJECT_NAME/-/jobs/$CI_JOB_ID/artifacts/public"

您还需要将mkdocs.yml更改为实际上使用PUBLIC_URL ,并确保在绝对内部链接中使用的所有地方生成:

You'll also need your change to mkdocs.yml to actually use the PUBLIC_URL, and make sure it's used everywhere that absolute internal links are generated:

site_url: !!python/object/apply:os.getenv ["PUBLIC_URL"]
use_directory_urls: false
…

这篇关于GitLab页面可以用于mkdocs项目上的审阅应用程序吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆