The magic around GitLab pages is in the name of the job. It has to be named "pages", and nothing else. It is possible to move the job to different stages. As soon as the job "pages" has finished successfully, there's a special type of job that is called "pages:deploy". This job is shown in the deploy stage even if you change the stage that the "pages" job is run in.
If you have the pages job in an early stage, jobs in the later stages can fail but the "pages:deploy" job will still run and update GitLab pages.
Other than that, the "pages" job is just like a normal job in GitLab. If you need artifacts from other jobs, you can get these by using artifacts and dependencies:
https://docs.gitlab.com/ee/ci/yaml/#dependencies
The "pages" job should create a folder named "public" and give that folder as an artifact.
Answer from MrBerta on Stack OverflowGreetings,
keep in mind that I come from github, where creating a github pages static website consists of just placing html files in a repository with the correct name.
I followed the guide to create a gitlab pages website. I created its script thing. Then it said it had no "runner" for the pipeline/job.
Then I created that runner, I installed gitlab-runner.exe as explained, copied the stuff it told me to copy in the command line, called gitlab-runner.exe run. The job started, and it failed. In the terminal that is running gitlab-runner I got this error:
ERROR: Job failed (system failure): prepare environment: failed to start process: exec: "pwsh": executable file not found in %PATH%. Check https://docs.gitlab.com/runner/shells/index.html#shell-profile-loading for more information duration_s=0.0085868 job=52 project=113 runner=uuj-sLTL2
I couldn't find a single gitlab guide that said anything specific about what else I need to do to setup this convoluted mess. The runners documentation doesn't mention pages deployment, the pages documentation doesn't mention runners at all.
What am I supposed to do? Where can I read about the setup steps that I'm evidently missing?
I'm also wondering, does the runner only take care of some behind-the-scenes process to build the website, and it'll be hosted in the gitlab server, or is the website going to be dependent on having the runner.exe process constantly active?
Sorry for the ranty tone, I just didn't expect this to eat up half a day.
Edit: it's likely relevant, we're not using the public gitlab website, we're using a self-hosted version within the company.
Edit edit: I fixed the issue, the runner now runs and the job completes. However i cannot access the pages page.Deploy doesn't contain any "pages" tab, only Releases, Feature flags, Package Registry. If I search "pages" in Settings/General I see an info box
GitLab Pages has moved
To go to GitLab Pages, on the left sidebar, select Deploy > Pages. ù
But the link it redirects to is a 404.
This is my .gitlab-ci.yml file:
image: alpine:latest
pages:
stage: deploy
script:
- echo 'Nothing to do...'
artifacts:
paths:
- public
only:
- masterAnd the public directory contains a hierarchy of html files and subdirectories. The master branch is master, no main/master issue either.
The magic around GitLab pages is in the name of the job. It has to be named "pages", and nothing else. It is possible to move the job to different stages. As soon as the job "pages" has finished successfully, there's a special type of job that is called "pages:deploy". This job is shown in the deploy stage even if you change the stage that the "pages" job is run in.
If you have the pages job in an early stage, jobs in the later stages can fail but the "pages:deploy" job will still run and update GitLab pages.
Other than that, the "pages" job is just like a normal job in GitLab. If you need artifacts from other jobs, you can get these by using artifacts and dependencies:
https://docs.gitlab.com/ee/ci/yaml/#dependencies
The "pages" job should create a folder named "public" and give that folder as an artifact.
The magic around GitLab pages is in the name of the job. It has to be named "pages", and nothing else.
Not anymore: See GitLab 17.6 (November 2024)
Deploy your Pages site with any CI/CD job
To give you more flexibility in designing your pipelines, you no longer need to name your Pages deploy job
pages.
You can now simply use thepagesattribute in any CI/CD job to trigger aPagesdeployment.
See Documentation and Issue.
Example:
deploy-my-pages-site:
stage: deploy
script:
- npm run build
pages: true # specifies that this is a Pages job
artifacts:
paths:
- public
If the
pagesproperty of a job namedpagesis set tofalse, no deployment is triggered
