专栏名称: F嘉阳
JAVA 后台开发
目录
相关文章推荐
安徽省发展改革委  ·  安徽省新能源汽车产业集群建设企业巡展——【2 ... ·  22 小时前  
安徽省发展改革委  ·  安徽省新能源汽车产业集群建设企业巡展——【2 ... ·  22 小时前  
51好读  ›  专栏  ›  F嘉阳

Docker 版 GitLab CICD 实践3——CI文件编写

F嘉阳  · 掘金  ·  · 2019-04-08 09:46

正文

阅读 4

Docker 版 GitLab CICD 实践3——CI文件编写

前置步骤:

官方文档

编写结构类似Jenkins pineline流水线

GitLab CI/CD Pipeline Configuration Reference

GitLab CI/CD Pipeline Configuration Reference

GitLab CI/CD pipelines are configured using a YAML file called .gitlab-ci.yml within each project.

The .gitlab-ci.yml file defines the structure and order of the pipelines and determines:

  • What to execute using GitLab Runner .
  • What decisions to make when specific conditions are encountered. For example, when a process succeeds or fails.

This topic covers CI/CD pipeline configuration. For other CI/CD configuration information, see:

We have complete examples of configuring pipelines:

目标

  • maven项目自动打包
  • 自动测试
  • 自动镜像构建并上传

官方参数表列出了作业的可用参数:

关键词 描述
script 由Runner执行的Shell脚本。
image 使用泊坞窗图像。也可用: image:name image:entrypoint
services 使用docker services图像。也可用: services:name services:alias services:entrypoint ,和 services:command
before_script 覆盖在作业之前执行的一组命令。
after_script 覆盖作业后执行的一组命令。
stages 定义管道中的阶段。
stage 定义作业阶段(默认值:) test
only 创建作业时限制。也可用: only:refs only:kubernetes only:variables ,和 only:changes
except 在未创建作业时限制。也可用: except:refs except:kubernetes except:variables ,和 except:changes
tags 用于选择Runner的标签列表。
allow_failure 让工作失败。失败的作业无助于提交状态。
when 什么时候开始工作。也可用: when:manual when:delayed
environment 作业部署到的环境的名称。也可用: environment:name environment:url environment:on_stop ,和 environment:action
cache 后续运行之间应缓存的文件列表。也可用: cache:paths cache:key cache:untracked ,和 cache:policy
artifacts 成功附加到作业的文件和目录列表。也可用: artifacts:paths artifacts:name artifacts:untracked artifacts:when artifacts:expire_in artifacts:reports ,和 artifacts:reports:junit 。 在GitLab 企业版 ,这些都是可供选择: artifacts:reports:codequality artifacts:reports:sast artifacts:reports:dependency_scanning artifacts:reports:container_scanning artifacts:reports:dast artifacts:reports:license_management ,和 artifacts:reports:performance
dependencies 作业所依赖的其他作业,以便您可以在它们之间传递工件。
coverage 给定作业的代码覆盖率设置。
retry 在发生故障的情况下,可以自动重试作业的次数和次数。
parallel 应该并行运行多少个作业实例。
trigger 定义下游管道触发器。
include 允许此作业包含外部YAML文件。也可用: include:local include:file include:template ,和 include:remote
extends 此作业将继承的配置条目。
pages 上传作业结果以用于GitLab Pages。
variables 在作业级别定义作业变量。

注: 参数 types type 弃用







请到「今天看啥」查看全文