Name | Updated at | |
---|---|---|
README.md |
不知道您是否有用疑问,当您监听的事件越来越多:
此时您不尽感叹道【我可不想当 YAML 工程师】。
配置在 VSCode 和 Jetbrains 种配置 JSON Schema
这里将介绍 YAML 的锚点(Anchors)和别名(Aliases),来帮助我们编写出可复用的 YAML 问题提升 YAML 的可维护性。
在阅读下面文章前,必须提前推荐一个工具 https://jsonformatter.org/yaml-parser
优化前:
master:
push:
- name: amd
runner:
tags: cnb:arch:amd64
services:
- docker
stages:
- name: uname
script: uname -a
- name: hello world
script: echo "hello world"
- name: arm
runner:
tags: cnb:arch:arm64:v8
services:
- docker
stages:
- name: uname
script: uname -a
- name: hello world
script: echo "hello world"
优化后:
# 锚点推荐 . 开头避免被识别成 branch 和 tag 名称
.build_script: &build_script
- name: uname
script: uname -a
- name: hello world
script: echo "hello world"
master:
push:
- name: amd
runner:
tags: cnb:arch:amd64
services:
- docker
stages:
*build_script
- name: arm
runner:
tags: cnb:arch:arm64:v8
services:
- docker
stages:
*build_script