问题
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 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.
回答1:
You do not have to create a new project if you already got one
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.
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
Source: https://about.gitlab.com/2016/04/07/gitlab-pages-setup/#add-gitlab-ci
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.
Edit:
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.
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
回答2:
Create a fork of that project, and setup the forked repo for the Gitlab Pages.
https://about.gitlab.com/2016/04/07/gitlab-pages-setup/#getting-started
There are two ways of getting started with GitLab Pages: either you fork an existing project, or you create a new one for yourself.
来源:https://stackoverflow.com/questions/55732375/how-to-activate-gitlab-pages-in-an-existing-project