Gitlab static mkdoc website does not work. What can be the reason for it? - gitlab

I want to include a Mkdoc into my gitlab repository. I followed the instruction on Mkdoc, but the website is not showing up. The error message ist displayed on the screenshot below.
I included the .gitlab-ci.yml file in the root file. This is the content:
image: python:latest
pages:
stage: deploy
only:
- master
script:
- pip install mkdocs-material
- mkdocs build --site-dir public
artifacts:
paths:
- public
I also included the mkdocs.yml and the docs folder on root. Is there anything else I must do?

Related

Gitlab Pages throw 404 when accessed

I have a group project with the following name (hosted in Gitlab): gitlab.com/my-group/my-project.
I have generated coverage reports during testing and saved them as artifacts using Gitlab CI. Here is Gitlab CI config:
test:
stage: test
image: node:11
before_script:
- npm install -g yarn
- yarn
cache:
paths:
- node_modules/
script:
- yarn lint
- yarn test --all --coverage src/
except:
- tags
artifacts:
paths:
- coverage/
coverage: '/Statements\s+\:\s+(\d+\.\d+)%/'
deploy-pages:
stage: deploy
dependencies:
- test
script:
- mv coverage/ public/
artifacts:
paths:
- public/
expire_in: 30 days
except:
- tags
When I open deploy stage job, I can see the artifact being created. Here is the screenshot: . All the files are under /public directory in the artifact.
Now, when I go to: https://my-group.gitlab.io/my-project, I keep getting 404.
I am not sure what step I am missing here. Can someone shed some light on this issue for me?
Thanks!
There are three basic requirements for the project itself:
project must be named group.gitlab.io (if you want it to be the base domain)
job must create artifact in public directory
job must be called pages
Most likely it's the last one that needs fixing since your job is currently called deploy-pages. Simply rename that to pages.
You'll know when you got everything working because under Settings > Pages, it will tell you the link where it's published to.

How to make the "shortcut" for gitlab pages available?

I have the following project: gitlab.com/username/project with a set CI script that generates some artifacts in public.
All the artifacts are correctly generated, and I can access my static site at
username.gitlab.io/-/project/-/jobs/<job-id>/artifacts/public
But when I try to access it with
username.gitlab.io/project
as stated in the documentation, I get a 404 error.
How to enable this shortcut?
The job must be named pages to activate Gitlab Pages:
pages:
stage: deploy
script:
- run script
artifacts:
paths:
- public
only:
- master

GitLab Pages, docs generated with sphinx

I want to host static page generated with Sphinx on GitLab Pages. Built index.html file is in:
project/docs/build/html
How .gitlab-ci.yml should look like to deploy the page? I have something like that and it isn't working:
pages:
stage: deploy
script:
- echo 'Nothing to do...'
artifacts:
paths:
- docs/build/html
only:
- master
According to the documentation for .gitlab-ci.yml, the pages job has special rules it must follow:
Any static content must be placed under a public/ directory
artifacts with a path to the public/ directory must be defined
So the example .gitlab-ci.yml you gave would look something like this:
pages:
stage: deploy
script:
- mv docs/build/html/ public/
artifacts:
paths:
- public
only:
- master
And of course, if you don't want to move the html folder for whatever reason, you can copy it instead.
For further reference, an example sphinx project for GitLab Pages was pushed around the time you originally posted this question.
image: python:3.10-alpine
stages:
- deploy
pages:
tags:
- sphinx
stage: deploy
script:
- python3 -m pip install sphinx furo
- sphinx-build -b html docs/source/ public/
artifacts:
paths:
- public
only:
- main # 'master' was renamed to 'main'
This is what my GitLab-ci.yml looks like.
On a side note: You don't need a public-folder in your repository. GitLab itself will handle it. I installed furo as theme (make sure to change the conf.py accordingly) to make it look nicer.

Gitlab CI not invoking the 'pages' job

I have a project hosted on Gitlab. The project website is inside the pages branch and is a jekyll based site.
My .gitlab-ci.yml looks like
pages:
script:
- gem install jekyll
- jekyll build -d public/
artifacts:
paths:
- public
only:
- pages
image: node:latest
cache:
paths:
- node_modules/
before_script:
- npm install -g gulp-cli
- npm install
test:
script:
- gulp test
When I pushed this configuration file to master, the pipeline executed only the test job and not pages job. I thought maybe pushing to master didn't invoke this job because only specifies pages branch. Then I tried pushing to pages branch but to no avail.
How can I trigger the pages job?
You're right to assume that the only constraint makes the job run only on the ref's or branches specified in the only clause.
See https://docs.gitlab.com/ce/ci/yaml/README.html#only-and-except
It could be that there's a conflict because the branch and the job have the same name. Could you try renaming the job to something different just to test?
I'd try a couple of things.
First, I'd put in this stages snippet at the top of the YML:
stages:
- test
- pages
This explicitly tells the CI to run the pages stage after the test stage is successful.
If that doesn't work, then, I'd remove the only tag and see what happens.
Complementing #rex answer's:
You can do either:
pages:
script:
- gem install jekyll
- jekyll build -d public/
artifacts:
paths:
- public
Which will deploy your site regardless the branch name, or:
pages:
script:
- gem install jekyll
- jekyll build -d public/
artifacts:
paths:
- public
only:
- master # or whatever branch you want to deploy Pages from
Which will deploy Pages from master.
Pls let me know if this helps :)

Moving artifact from Gitlab CI to project Wiki page

I'm setting up Gitlab CI to create an asciidoc page from a Swagger YAML specification.
To this end, I've set up Gitlab to execute the swagger maven plugin and save the results to the public artifacts folder, like this:
enter codedeploy:jdk8:
stage: test
script:
- 'mvn $MAVEN_CLI_OPTS swagger2markup:convertSwagger2markup'
#only:
# - master
# Archive up the built documentation site.
artifacts:
paths:
- target/asciidoc
image: maven:3.3.9-jdk-8
pages:
image: busybox:latest
stage: deploy
script:
- mv target/asciidoc public
dependencies:
- deploy:jdk8
artifacts:
paths:
- public
#only:
# - master
My question is how to automatically upload the resulting asciidoc artifacts as wiki pages in my Gitlab project. I can browse the public artifacts folder but Gitlab doesn't render the .adoc files in there, it only offers to download them.
Update. I found Gitlab issue 18106 which is a feature request to "allow runners to push via their CI token". I think this feature would be the answer to my question, or does anyone have a better idea?

Resources