当持续集成通过并构建工件时,如何在GitLab页面上生成鹈鹕网站? [英] How to get pelican site generate on GitLab Pages when continuous integration passes and artifacts are being built?

查看:124
本文介绍了当持续集成通过并构建工件时,如何在GitLab页面上生成鹈鹕网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用鹈鹕作为静态站点生成器来构建静态站点.我想将其托管在GitLab Pages上,并通过GitLab与Makefile的持续集成来生成网站.

I used pelican as the static site generator to build a static site. I wanted to host it on GitLab Pages and let the site generate with GitLab's continuous integration with Makefile.

该站点可以通过其CI/CD管道在本地以及在GitLab上成功构建. 构建代码通过上传的工件并成功完成工作.内容文件在public文件夹中生成和生成.

The site successfully builds locally as well as on GitLab via its CI/CD pipeline. The build code passes with artifacts uploaded and job succeeded. The content files are built and produced in the public folder.

以某种方式,在根据需要传递了构建并将工件上载到public文件夹后,应该将静态站点托管在GitLab页面的用户页面上,例如username.gitlab.io/projectname.

Somehow, after the build being passed and artifacts being uploaded in public folder as desired, it was expected to have the static site hosted on the user pages of GitLab Pages like username.gitlab.io/projectname.

尽管建议的等待时间为15分钟到半小时,但即使经过15个小时以上,它也无法正常工作.

This did not work even after 15+ hours though the recommended wait time was fifteen minutes to half an hour.

还尝试了在自定义子域上托管.子域已验证,但尚未生成网站.

Hosting on a custom subdomain was also tried. The subdomain is verified, yet the site is not being generated.

为便于参考,下面将介绍最少使用的代码.

For reference, minimal code in use is mentioned below.

# default to using the latest Python docker image for builds
image: python:3.7.0

# our build job installs the Python requirements and Pelican
# plugins, then runs ``make publish`` to generate the output
build:
  stage: deploy
  script:
  - apt-get update -qq && apt-get install -y -qq python python-pip
  - python -v
  - pip install  -r requirements.txt
  - git clone --recursive https://github.com/getpelican/pelican-plugins ../plugins
  - pelican -s publishconf.py
  - make publish
# specify the artifacts to save
  artifacts:
    paths:
      - public/
  only:
  - master

publishconf.py

#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
import os

AUTHOR = 'Tanya Jain'
SITENAME = 'Tanya Jain'
SITEURL = '/public'
DESCRIPTION = ''
THEME = 'themes/stellarAdventurerTheme'

PATH = 'content'
OUTPUT_PATH = 'public'

pelicanconf.py

#!/usr/bin/env python
# -*- coding: utf-8 -*- #
from __future__ import unicode_literals
import os

AUTHOR = 'Tanya Jain'
SITENAME = 'Tanya Jain'
SITEURL = '/public'
DESCRIPTION = ''
THEME = 'themes/stellarAdventurerTheme'

PATH = 'content'
OUTPUT_PATH = 'public'

Makefile

PY?=python3
PELICAN?=pelican
PELICANOPTS=

BASEDIR=$(CURDIR)
INPUTDIR=$(BASEDIR)/content
OUTPUTDIR=$(BASEDIR)/public
CONFFILE=$(BASEDIR)/pelicanconf.py
PUBLISHCONF=$(BASEDIR)/publishconf.py

FTP_HOST=localhost
FTP_USER=anonymous
FTP_TARGET_DIR=/

SSH_HOST=localhost
SSH_PORT=22
SSH_USER=root
SSH_TARGET_DIR=/var/www

请提供有关如何在GitLab页面上生成网站的帮助!

Kindly help out on how to generate the site on GitLab Pages!

尝试了这些也不起作用的更改.但是,我相信这些更改将在鹈鹕环境中进行,而不是在GitLab的YAML中进行.

Tried these changes which too did not work. Yet, I believe the changes are to be made in the pelican settings and not the GitLab's YAML.

SITEURL = ''

publishconf.py

SITEURL = 'http://subdomain.example.com'

推荐答案

非常感谢您的帮助!我已经解决了问题.该错误是由于在.gitlab-ci.yml中将该作业称为build所致,并且还缺少该作业pages.使用pages作为作业是部署GitLab页面的必要条件,可以进一步阅读提及的参考资料.因此,正确的脚本应该是:

Thanks a lot for helping out! I have solved the problem. The error was due to mentioning the job as build in .gitlab-ci.yml and also, missing of the job pages. Using pages as a job is a necessity of the GitLab Pages to be deployed, which can further read in the references mentioned. Hence, the correct script would be:

image: python:3.7.0

pages:
    stage: deploy
    script:
    - apt-get update -qq && apt-get install -y -qq python python-pip
    - python -v
    - pip install  -r requirements.txt
    - git clone --recursive https://github.com/getpelican/pelican-plugins ../plugins
    - pelican -s publishconf.py
    - make publish
    artifacts:
        paths:
            - public/
    only:
    - master

参考文献:

  1. Stackoverflow:成功构建后,GitLab页面部署步骤失败
  2. 浏览GitLab页面(文档)
  3. 为GitLab页面创建和调整GitLab CI/CD
  1. Stackoverflow: GitLab Pages deployment step fails after successfull build
  2. Exploring GitLab Pages (documentation)
  3. Creating and Tweaking GitLab CI/CD for GitLab Pages

这篇关于当持续集成通过并构建工件时,如何在GitLab页面上生成鹈鹕网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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