Upload/Get/Delete metadata, metadata is an annotation for tag or commit, used to store associated data.
cnbcool/annotations:latest
The following events support Upload, Get, Delete metadata operations:
The following events only support Get metadata, not Upload and Delete metadata:
key:value format
Currently, metadata can be stored for tag or commit:
tag: Metadata is an annotation for tagcommit: Metadata is an annotation for commitIdtype: Operation type, default is ADD.
ADD: Upload metadata, other available parameters: data, fromJsonFile.DELETE: Delete metadata, other available parameter: keyGET: Get metadata, other available parameter: toFiledata: Metadata to be uploaded. Valid when type: ADD.
Supports the following two formats (choose one, \n is preferred).
When using ; as separator, it cannot contain \n.
Metadata key cannot be empty, empty keys will be filtered out,
and can only contain 0-9, a-z, A-Z, _, -.
When metadata value may contain \n or ;,
it is recommended to encode the value or use fromJsonFile to input data
to avoid unexpected results.
key1=value1;key2=value2;key3=value3key1=value1\nkey2=value2\nkey3=value3key: Supports multiple keys, separated by English semicolons, English commas, or line breaks. When type: DELETE,
it indicates the metadata key to be deleted.toFile: Valid when type: GET. Stores the queried data in JSON string format to the specified file, input relative
path (e.g., text.json)fromJsonFile: Valid when type: ADD.
JSON data (e.g., {"key1": "value1","key2":"value2"}) stored in a relative path file (e.g., text.json).
When both data and fromJsonFile are provided, both are effective, but for the same key, data from data takes
precedence.tag: Tag name, optional. Operates on metadata for the specified tag.commit: commitID, long hash, optional. Operates on metadata for the specified commit.When neither tag nor commit is provided, the default metadata carrier is:
tag_push and tag_deploy.* events: Default operation is on tag metadata. tag takes the environment variable
CNB_BRANCHcommit metadata. commit takes the environment variable CNB_COMMITmain:
# Upload metadata in push event, data is annotation for commitId
push:
- stages:
- name: Upload Metadata
image: cnbcool/annotations:latest
settings:
# Four ways to input data
# Method 1: Multi-line text format example, actually separated by \n
data: |
key1=value1
key2=value2
# Method 2: Separated by semicolons
# data: key1=value1;key2=value2
# Method 3: Separated by \n
# data: key1=value1\nkey2=value2
# Method 4: Read data from file
# fromFile: text.json
type: ADD
$:
# Upload metadata in tag_push event, data is annotation for tag
tag_push:
- stages:
- name: Upload Metadata
image: cnbcool/annotations:latest
settings:
# Four ways to input data
# Method 1: Multi-line text format example, actually separated by \n
data: |
key1=value1
key2=value2
# Method 2: Separated by semicolons
# data: key1=value1;key2=value2
# Method 3: Separated by \n
# data: key1=value1\nkey2=value2
# Method 4: Read data from file
# fromFile: text.json
type: ADD
main:
# Upload metadata for specified tag in non-tag_push/tag_deploy.* events
api_trigger_test:
- stages:
- name: Upload Metadata
image: cnbcool/annotations:latest
settings:
# Four ways to input data
# Method 1: Multi-line text format example, actually separated by \n
data: |
key1=value1
key2=value2
# Method 2: Separated by semicolons
# data: key1=value1;key2=value2
# Method 3: Separated by \n
# data: key1=value1\nkey2=value2
# Method 4: Read data from file
# fromFile: text.json
type: ADD
tag: v1.0.0
main:
# Delete metadata in push event, deleting commitId metadata
push:
- stages:
- name: Delete Metadata
image: cnbcool/annotations:latest
settings:
# Supports semicolon, \n separation, or multi-line text
key: key1;key2;key3
type: DELETE
$:
# Delete metadata in tag_push event, deleting tag metadata
tag_push:
- stages:
- name: Delete Metadata
image: cnbcool/annotations:latest
settings:
# Supports semicolon, \n separation, or multi-line text
key: key1;key2;key3
type: DELETE
main:
# Delete metadata for specified tag in non-tag_push/tag_deploy.* events
api_trigger_test:
- stages:
- name: Delete Metadata
image: cnbcool/annotations:latest
settings:
# Supports semicolon, \n separation, or multi-line text
key: key1;key2;key3
type: DELETE
tag: v1.0.0
main:
# Get metadata in push event, getting commitId metadata
push:
- stages:
- name: Get Metadata
image: cnbcool/annotations:latest
settings:
type: GET
exports:
# annotations is all metadata in JSON string format
# Example: "{"key1":"value1","key2":"value2","key3":"value3"}"
annotations: ANNOTATIONS
key1: KEY1
key2: KEY2
key3: KEY3
- name: Output Metadata
script:
- echo $ANNOTATIONS
- echo $KEY1
- echo $KEY2
- echo $KEY3
$:
# Get metadata in tag_push event, getting tag metadata
tag_push:
- stages:
- name: Get All Metadata
image: cnbcool/annotations:latest
settings:
type: GET
exports:
# annotations is all metadata in JSON string format
# Example: "{"key1":"value1","key2":"value2","key3":"value3"}"
annotations: ANNOTATIONS
key1: KEY1
key2: KEY2
key3: KEY3
- name: Output Metadata
script:
- echo $ANNOTATIONS
- echo $KEY1
- echo $KEY2
- echo $KEY3
main:
# Get metadata for specified tag in non-tag_push/tag_deploy.* events
api_trigger_test:
- stages:
- name: Get All Metadata
image: cnbcool/annotations:latest
settings:
type: GET
tag: v1.0.0
exports:
# annotations is all metadata in JSON string format
# Example: "{"key1":"value1","key2":"value2","key3":"value3"}"
annotations: ANNOTATIONS
key1: KEY1
key2: KEY2
key3: KEY3
- name: Output Metadata
script:
- echo $ANNOTATIONS
- echo $KEY1
- echo $KEY2
- echo $KEY3