-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
王艺
committed
Jul 9, 2024
1 parent
b6c52d4
commit 3eb002a
Showing
1 changed file
with
42 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
--- | ||
title: Gitlab CI/CD 配置手册 | ||
tags: | ||
- CI/CD | ||
date: 2024-07-09 16:45 | ||
category: | ||
- Gitlab | ||
--- | ||
|
||
## 产物 | ||
|
||
gitlab 支持将作业完成时生成的文件或文件夹保存下来,这也产物可以在后续的作业中使用或下载,以实现资源的传递和共享。 | ||
|
||
他的关键字时 `artifacts` | ||
|
||
**使用方式** | ||
|
||
```yaml | ||
build_job: | ||
script: | ||
- npm install | ||
- npm run build | ||
artifacts: | ||
paths: | ||
- dist/ | ||
``` | ||
在上面的示例中,build_job 作业执行构建过程后会生成一个名为 dist/ 的目录作为产物。这个目录中包含了构建后的静态文件。这些产物可以在后续的作业中使用,例如部署到服务器上或者进行测试。 | ||
**产物路径** | ||
paths 关键字用于指定需要保留的产物路径。可以是文件或者目录。在示例中,dist/ 表示保留整个 dist 目录及其下的所有文件。 | ||
**其他属性** | ||
除了 `paths` 关键字外,还可以通过其他属性对产物进行更详细的配置,如 `expire_in` 用于设置产物过期时间、`name` 用于指定产物的名称等。 | ||
|
||
**作用域** | ||
|
||
产物默认是作业级别的,即只能在同一个作业流程中的后续作业中使用。如果希望跨作业流程共享产物,可以使用 `dependencies` 关键字将产物传递给其他作业。 | ||
|
||
通过使用 `artifacts` 关键字,可以方便地将作业生成的产物保留下来,以供后续作业使用。这种机制实现了作业之间的数据共享和传递,使得 **CI/CD** 流程更加灵活和高效。 |