Kubernetes/CICD/Drone/YML/.drone-build-webhook.yml
offends 7a2f41e7d6
All checks were successful
continuous-integration/drone Build is passing
synchronization
2024-08-07 18:54:39 +08:00

72 lines
1.9 KiB
YAML

kind: pipeline
type: docker
name: Build Dockerfile
# 手动触发或接口触发
trigger:
event:
- custom
# 指定架构,需在 runner 配置环境变量中指定 DRONE_RUNNER_ARCH,或自动获取
# platform:
# os: linux
# arch: amd64
# 指定运行环境节点,需在 runner 配置环境变量中指定 DRONE_RUNNER_LABELS
# node:
# 标签:值
# 使用插件构建镜像
steps:
- name: Build Dockerfile
image: plugins/docker
# 仅当本地不存在该镜像时才拉取
pull: if-not-exists
settings:
registry:
from_secret: REGISTRY
username:
from_secret: DOCKER_USERNAME
password:
from_secret: DOCKER_PASSWORD
repo:
from_secret: REPO
# 是否禁止推送镜像
dry_run: false
tags:
- latest
# 要使用的上下文路径,默认为 git 存储库的根目录
context: ./
# 要使用的 dockerfile 路径,默认为 git 存储库的根目录
dockerfile: ./Dockerfile
- name: 结果通知
image: plugins/webhook
depends_on: [Build Dockerfile]
settings:
urls:
from_secret: WEBHOOK_URL
# # 飞书机器人
# 官网飞书机器人使用指南: https://open.feishu.cn/document/client-docs/bot-v3/add-custom-bot
# 消息类型指南: https://open.feishu.cn/community/articles/7271149634339422210
method: POST
content_type: "application/json"
# 通知内容,读取上一步执行结果,如果成功则返回构建成功,失败则返回构建失败
template: >
{
"msg_type": "text",
"content": {
"text":
{{#success build.status}}
"镜像构建成功"
{{else}}
"镜像构建失败"
{{/success}}
}
}
# 无论构建成功或失败都通知
when:
status:
- success
- failure