使用下游阶段部署 gitlab 页面
Deploy gitlab pages using downstream stage
这是我的文件夹树:
proj/
├─ src/
├─ docs/
│ ├─ public/
│ │ ├─ assets/
│ │ ├─ index.html
│ ├─ .gitlab-ci.yml
├─ config/
├─ .gitlab-ci.yml
如您所见,有两个 .gitlab-ci.yml
文件。第一个,在项目的根目录中是触发第二个进入 docs
文件夹的 master
管道。除了部署应用程序(仅在特定分支上)之外,我希望第一个管道触发第二个管道并将文档部署到 giltab pages
。
这是docs/.gitlab-ci.yml
的代码:
image: alpine:latest
pages:
stage: deploy
script:
- echo 'Nothing to do...'
artifacts:
paths:
- public/
expire_in: 1 day
这是项目根目录中的.gitlab-ci.yml
:
stages:
- deploy-docs
- gen-text
- deploy-in-dev
gen-text:
stage: gen-text
image: python:3.10.0
before_script:
- pip3 install -r ./command/requirements.txt
script:
- python3 ./command/main.py
artifacts:
paths:
- src/languages
expire_in: 1 day
only: ['stg']
deploy-in-dev:
stage: deploy-in-dev
image: node:latest
dependencies:
- gen-text
script:
- echo 'Only stg with artifacts'
only: ['stg']
docs:
stage: deploy-docs
trigger:
include: docs/.gitlab-ci.yml
管道正确触发下游但失败:missing pages artifacts
。
那么,我如何才能将 public 文件夹传递给下游以及为什么辅助 .gitlab-ci.yml
看不到该文件夹?
问题似乎与您为下游工件提供的路径有关
paths:
- public/
你应该把它改成
paths:
- docs/public/
当您包含子管道时,当前工作目录不会改变,它仍然在 proj/
而不是 docs/
这是我的文件夹树:
proj/
├─ src/
├─ docs/
│ ├─ public/
│ │ ├─ assets/
│ │ ├─ index.html
│ ├─ .gitlab-ci.yml
├─ config/
├─ .gitlab-ci.yml
如您所见,有两个 .gitlab-ci.yml
文件。第一个,在项目的根目录中是触发第二个进入 docs
文件夹的 master
管道。除了部署应用程序(仅在特定分支上)之外,我希望第一个管道触发第二个管道并将文档部署到 giltab pages
。
这是docs/.gitlab-ci.yml
的代码:
image: alpine:latest
pages:
stage: deploy
script:
- echo 'Nothing to do...'
artifacts:
paths:
- public/
expire_in: 1 day
这是项目根目录中的.gitlab-ci.yml
:
stages:
- deploy-docs
- gen-text
- deploy-in-dev
gen-text:
stage: gen-text
image: python:3.10.0
before_script:
- pip3 install -r ./command/requirements.txt
script:
- python3 ./command/main.py
artifacts:
paths:
- src/languages
expire_in: 1 day
only: ['stg']
deploy-in-dev:
stage: deploy-in-dev
image: node:latest
dependencies:
- gen-text
script:
- echo 'Only stg with artifacts'
only: ['stg']
docs:
stage: deploy-docs
trigger:
include: docs/.gitlab-ci.yml
管道正确触发下游但失败:missing pages artifacts
。
那么,我如何才能将 public 文件夹传递给下游以及为什么辅助 .gitlab-ci.yml
看不到该文件夹?
问题似乎与您为下游工件提供的路径有关
paths:
- public/
你应该把它改成
paths:
- docs/public/
当您包含子管道时,当前工作目录不会改变,它仍然在 proj/
而不是 docs/