Gitlab提供了一个.gitlab-ci.yml模板,用于构建图像并将其发布到自己的注册表中(单击其中一个项目中的“新建文件”,选择.gitlab-ci.yml和docker)。该文件如下所示,并且开箱即用:)
# This file is a template, and might need editing before it works on your project.
# Official docker image.
image: docker:latest
services:
- docker:dind
before_script:
- docker login -u &
我用的是打字稿。在本地,我将eslint配置为将未使用的变量视为警告。
当我在本地运行npm run build时,它可以工作,但在gitlab中,我得到了以下错误:
npm run build
> optimal-move@0.1.0 build
> react-scripts build
Creating an optimized production build...
Treating warnings as errors because process.env.CI = true.
Most CI servers set it automatically.
Failed
让我们想象一下,我想在gitlab中拥有两个不同的CI管道。第一个应该从任何分支上的每次推送开始,而另一个只有在提交标题以部署结束时才开始。
我怎么能意识到这一点?
所以我的想法是:
.gitlab-ci.yml
stages:
- pre
- build
include:
- local: ci/a.gitlab-ci.yml
- local: ci/b.gitlab-ci.yml
a.gitlab-ci.yml
workflow:
rules:
# only triggered by "-deploy" at the end of commit