如何在现有项目中激活GitLab页面? [英] How to activate GitLab Pages in an existing project?

查看:157
本文介绍了如何在现有项目中激活GitLab页面?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想发布我的Java项目的代码覆盖率报告,该报告已经在GitLab上已经了。我使用JaCoCo在 app / target / site / jacoco / 的文件夹中生成代码覆盖率报告。

I want to publish my code coverage reports for my Java project that is already on GitLab. I generate code coverage reports with JaCoCo in a folder located in app/target/site/jacoco/.

I看到我必须激活GitLab页面。但这在GitLab文档上的链接说我必须创建一个新项目。我的Java项目已经在GitLab项目中已经,在这种情况下我不知道该怎么做。

I saw I had to activate GitLab Pages. But this link on the GitLab documentation say I have to create a new project. My Java project is already in a GitLab Project and I don't know how to do in that case.

推荐答案

如果您已经拥有一个项目,则不必创建一个新项目

GitLab文档对此有些困惑。该文档的意思是,您可以使用另一个模板项目中的现有一个,开始使用Pages配置。这并不意味着您只能在新项目中使用GitLab页面。

The GitLab documentation is a little confusing about this. What the documentation means is you can get started with your Pages configuration by using an existing one of another template project. It does not mean you can only use GitLab Pages with new projects.

要在项目中使用GitLab页面,请放置 .gitlab-ci。 yml 在存储库的根目录中。在这里,您可以指定如何生成和发布GitLab页面网站的内容,例如

To use GitLab pages in your project, place a .gitlab-ci.yml in the root directory of your repository. Here, you can specify how the content of your GitLab Pages site should be generated and published, e.g.

pages:
  stage: deploy
  script:
  - mkdir .public
  - cp -r * .public
  - mv .public public
  artifacts:
    paths:
    - public
  only:
  - master

来源: https://about.gitlab.com/2016 / 04/07 / gitlab-pages-setup /#add-gitlab-ci

TL,DR GitLab页面配置在CI / CD配置文件( .gitlab-ci.yml )中定义。您不仅可以在创建新项目时随时添加或更改此文件。

TL,DR The GitLab Pages configuration is defined in your CI/CD configuration file (.gitlab-ci.yml). You can add or change this file at any point, not only when you create a new project.

编辑:

发布的静态内容必须位于项目根目录的公共文件夹中。没有办法解决。但是,这不是问题,您只需在CI / CD期间将内容移动到那里,就不需要更改存储库内容本身。


The published static content has to be in the public folder in the root of your project. There is no way around that. However, this is not a problem, you can simply move your stuff there during CI/CD, you do not need to change the repository content itself.

如果要发布 app / target / site / jacoco ,您可以执行以下操作:

If you want to publish app/target/site/jacoco, you can do:

pages:
  stage: deploy
  script:
  - mv app/target/site/jacoco/ public
  artifacts:
    paths:
    - public
  only:
  - master

这篇关于如何在现有项目中激活GitLab页面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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