CNB 自动 Docker 标签插件,自动管理 Docker 镜像的 tag 版本号。
插件支持以下 tag 格式模板:
tagFormat: "v@{version}"
生成示例:v1.0.1、v1.0.2、v1.1.0
版本递增规则:
v1.0.1示例:
v1.0.1 → v1.0.2v1.0.99 → v1.1.0v1.99.99 → v2.0.0tagFormat: "v@{auto}"
生成示例:v1、v2、v3
版本递增规则:
v1tagFormat: "@{yyyyMMdd}-v@{version}"
生成示例:20260325-v1.0.1
tagFormat: "@{yyyyMMdd}-v@{auto}"
生成示例:20260325-v1
日期处理规则:
@{yyyyMMdd} 会被替换为当前日期(如 20260325)在 .cnb.yml 流水线配置中使用:
stages:
- name: auto-docker-tag
image: docker.cnb.cool/r_r/auto-docker-tag:latest
settings:
tagFormat: "v@{version}"
stringCNB_REPO_SLUG_LOWERCASE)示例:
stages:
- name: auto-docker-tag
image: docker.cnb.cool/r_r/auto-docker-tag:latest
settings:
slug: "other-owner/other-repo"
stringdockerdocker。stringCNB_REPO_SLUG_LOWERCASE),取最后一个 / 后面的值(同名镜像)示例:
stages:
- name: auto-docker-tag
image: docker.cnb.cool/r_r/auto-docker-tag:latest
settings:
imageName: "my-custom-image"
stringv@{version}@{version}、@{auto}、@{yyyyMMdd}、@{yyyyMMdd}-v@{auto} 占位符。示例:
stages:
- name: auto-docker-tag
image: docker.cnb.cool/r_r/auto-docker-tag:latest
settings:
tagFormat: "@{yyyyMMdd}-v@{version}"
stringCNB_API_ENDPOINT)https://api.cnb.cool。stringCNB_TOKEN)插件会输出以下流水线变量:
##[set-output auto-docker-tag=v1.0.1]
##[set-output auto-docker-tag-url=docker.cnb.cool/h_h/images/aws-freetier-monitor:v1.0.1]
main:
push:
- stages:
- name: auto-docker-tag
image: docker.cnb.cool/r_r/auto-docker-tag:latest
settings:
slug: "other-owner/other-repo"
imageName: "my-image"
tagFormat: "v@{version}"
exports:
auto-docker-tag: DOCKER_TAG
auto-docker-tag-url: DOCKER_TAG_URL
- name: echo env
script:
- echo "DOCKER_TAG $DOCKER_TAG"
- echo "DOCKER_TAG_URL $DOCKER_TAG_URL"
main:
push:
- stages:
- name: auto-docker-tag
image: docker.cnb.cool/r_r/auto-docker-tag:latest
settings:
tagFormat: "@{yyyyMMdd}-v@{auto}"
main:
push:
- stages:
- name: auto-docker-tag-other-repo
image: docker.cnb.cool/r_r/auto-docker-tag:latest
settings:
slug: "other-owner/other-repo"
imageName: "my-image"
endpoint: "https://api.cnb.cool"
token: "${OTHER_REPO_TOKEN}"
遇到以下情况时,插件会退出并返回非零状态码,导致流水线失败:
MIT License