首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >是否在CI作业期间停止GitLab跳过Git子模块?

是否在CI作业期间停止GitLab跳过Git子模块?
EN

Stack Overflow用户
提问于 2021-06-20 10:11:54
回答 2查看 1.3K关注 0票数 1

我正在测试如何在GitLab页面上部署一个十六进制站点。我目前使用的是有人发布到GitHub上的一个主题,因此在我的Hexo项目的themes文件夹中有一个Git子模块,使得顶级.gitmodules文件看起来像这样:

代码语言:javascript
运行
复制
[submodule "themes/Hacker"]
    path = themes/Hacker
    url = https://github.com/CodeDaraW/Hacker.git

我使用Hexo文档推荐的YAML文件(针对当前节点更新)进行CI设置,CI工作似乎进展顺利,只是它随机决定跳过Git子模块设置:

代码语言:javascript
运行
复制
Getting source from Git repository 00:01
$ eval "$CI_PRE_CLONE_SCRIPT"
Fetching changes with git depth set to 50...
Initialized empty Git repository in /builds/jjeffrey/jjeffrey.gitlab.io/.git/
Created fresh repository.
Checking out 76f8757a as master...
Skipping Git submodules setup
Restoring cache 00:01
Checking cache for default...
FATAL: file does not exist

这会阻止站点正确生成HTML/CSS文件,因为不存在主题:

代码语言:javascript
运行
复制
$ hexo generate
INFO  Validating config
INFO  Start processing
INFO  Files loaded in 100 ms
WARN  No layout: 1970/01/01/hello-world/index.html
WARN  No layout: 1970/01/01/test_new/index.html
WARN  No layout: archives/index.html
WARN  No layout: archives/1970/index.html
WARN  No layout: archives/1970/01/index.html
WARN  No layout: index.html
INFO  Generated: archives/index.html
INFO  Generated: archives/1970/index.html
INFO  Generated: archives/1970/01/index.html
INFO  Generated: index.html
INFO  Generated: 1970/01/01/hello-world/index.html
INFO  Generated: 1970/01/01/test_new/index.html
INFO  6 files generated in 13 ms

如何确保GitLab正确加载Git子模块,以便加载我的主题?

EN

回答 2

Stack Overflow用户

发布于 2021-06-20 23:57:47

来自gitlab documenation Using Git submodules with GitLab CI/CD

在CI/CD作业中使用Git子模块

要使子模块在CI/CD作业中正常工作,请执行以下操作:

  1. 请确保对位于同一GitLab服务器中的子模块使用相对URL。

  1. 您可以将GIT_SUBMODULE_STRATEGY变量设置为normal或recursive,以告诉运行器在作业之前获取您的子模块:

变量: GIT_SUBMODULE_STRATEGY: recursive

另请参阅https://docs.gitlab.com/ee/ci/runners/configure_runners.html#git-submodule-strategy

票数 1
EN

Stack Overflow用户

发布于 2021-06-20 20:53:58

我通过向.gitlab-ci.yml添加一行代码来更新Git子模块,然后再继续脚本的其余部分,从而解决了这个问题。

代码语言:javascript
运行
复制
image: node:14.17.1
cache:
  paths:
    - node_modules/

before_script:
  - git submodule update --init
  - npm install hexo-cli -g
  - npm install

pages:
  script:
    - hexo generate
  artifacts:
    paths:
      - public
  only:
    - master
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68052124

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档