---
url: /en/develops/badge.md
description: >
  Explains how to use CNB badges to display build metrics with color-coded
  status indicators, including badge access paths, types, and embedding them in
  README files.
---
Badges display metric data, using color to indicate whether standards are met.

## Cloud Native Build Related Badges

### Badge Access Path

Badge access paths for cloud native builds:

* precise: `https://cnbprod.alpha.qq.com/{group}/{repository}/-/badge/git/{sha}/{metrics}`

* latest: `https://cnbprod.alpha.qq.com/{group}/{repository}/-/badge/git/latest/{metrics}`

* branch latest: `https://cnbprod.alpha.qq.com/{group}/{repository}/-/badge/git/latest/{metrics}?branch={branch}`

* Parameter descriptions:
  * `group`: Organization path of the repository
  * `repository`: Repository name
  * `sha`: First 8 characters of the CommitId
  * `latest`: When branch is not specified, fetches the badge for the latest default branch commit; when specified,
    fetches the badge for the latest commit of that branch
  * `metrics`: Metric name, e.g., `ci/status/push`, representing the build time triggered by push events
  * `branch`: Branch name, e.g., `main`, only effective when sha is `latest`

### Badge Types

During cloud native builds, badge data for build metrics is automatically reported:

#### 1. Git Events

##### `ci/status/push` {#badge-ci-status-push}

Push event build time and status

![push event](//cnbprod.alpha.qq.com/svg/badge/push?message=pending%2C%2010s\&color=pending)
![push event](//cnbprod.alpha.qq.com/svg/badge/push?message=success%2C%2010s\&color=success)
![push event](//cnbprod.alpha.qq.com/svg/badge/push?message=failure%2C%2010s\&color=failure)

##### `ci/status/commit.add` {#badge-ci-status-commit-add}

Commit add event build time and status

![commit.add event](//cnbprod.alpha.qq.com/svg/badge/commit.add?message=pending%2C%2010s\&color=pending)
![commit.add event](//cnbprod.alpha.qq.com/svg/badge/commit.add?message=success%2C%2010s\&color=success)
![commit.add event](//cnbprod.alpha.qq.com/svg/badge/commit.add?message=failure%2C%2010s\&color=failure)

##### `ci/status/branch.create` {#badge-ci-status-branch-create}

Branch create event build time and status

![branch.create event](//cnbprod.alpha.qq.com/svg/badge/branch.create?message=pending%2C%2010s\&color=pending)
![branch.create event](//cnbprod.alpha.qq.com/svg/badge/branch.create?message=success%2C%2010s\&color=success)
![branch.create event](//cnbprod.alpha.qq.com/svg/badge/branch.create?message=failure%2C%2010s\&color=failure)

##### `ci/status/pull_request` {#badge-ci-status-pull-request}

Pull request event build time and status

![pull\_request event](//cnbprod.alpha.qq.com/svg/badge/pull_request?message=pending%2C%2010s\&color=pending)
![pull\_request event](//cnbprod.alpha.qq.com/svg/badge/pull_request?message=success%2C%2010s\&color=success)
![pull\_request event](//cnbprod.alpha.qq.com/svg/badge/pull_request?message=failure%2C%2010s\&color=failure)

##### `ci/status/pull_request.update` {#badge-ci-status-pull-request-update}

Pull request update event build time and status

![pull\_request.update event](//cnbprod.alpha.qq.com/svg/badge/pull_request.update?message=pending%2C%2010s\&color=pending)
![pull\_request.update event](//cnbprod.alpha.qq.com/svg/badge/pull_request.update?message=success%2C%2010s\&color=success)
![pull\_request.update event](//cnbprod.alpha.qq.com/svg/badge/pull_request.update?message=failure%2C%2010s\&color=failure)

##### `ci/status/pull_request.target` {#badge-ci-status-pull-request-target}

Pull request target event build time and status

![pull\_request.target event](//cnbprod.alpha.qq.com/svg/badge/pull_request.target?message=pending%2C%2010s\&color=pending)
![pull\_request.target event](//cnbprod.alpha.qq.com/svg/badge/pull_request.target?message=success%2C%2010s\&color=success)
![pull\_request.target event](//cnbprod.alpha.qq.com/svg/badge/pull_request.target?message=failure%2C%2010s\&color=failure)

##### `ci/status/pull_request.merged` {#badge-ci-status-pull-request-merged}

Pull request merged event build time and status

![pull\_request.merged event](//cnbprod.alpha.qq.com/svg/badge/pull_request.merged?message=pending%2C%2010s\&color=pending)
![pull\_request.merged event](//cnbprod.alpha.qq.com/svg/badge/pull_request.merged?message=success%2C%2010s\&color=success)
![pull\_request.merged event](//cnbprod.alpha.qq.com/svg/badge/pull_request.merged?message=failure%2C%2010s\&color=failure)

##### `ci/status/pull_request.approved` {#badge-ci-status-pull-request-approved}

Pull request approved event build time and status

![pr.approved event](//cnbprod.alpha.qq.com/svg/badge/pull_request.approved?message=pending%2C%2010s\&color=pending)
![pr.approved event](//cnbprod.alpha.qq.com/svg/badge/pull_request.approved?message=success%2C%2010s\&color=success)
![pr.approved event](//cnbprod.alpha.qq.com/svg/badge/pull_request.approved?message=failure%2C%2010s\&color=failure)

##### `ci/status/pull_request.changes_requested` {#badge-ci-status-pull-request-changes-requested}

Pull request changes requested event build time and status

![pr.changes\_requested event][pr-cr-pending]
![pr.changes\_requested event][pr-cr-success]
![pr.changes\_requested event][pr-cr-failure]

[pr-cr-pending]: //cnbprod.alpha.qq.com/svg/badge/pull_request.changes_requested?message=pending%2C%2010s&color=pending

[pr-cr-success]: //cnbprod.alpha.qq.com/svg/badge/pull_request.changes_requested?message=success%2C%2010s&color=success

[pr-cr-failure]: //cnbprod.alpha.qq.com/svg/badge/pull_request.changes_requested?message=failure%2C%2010s&color=failure

##### `ci/status/pull_request.mergeable` {#badge-ci-status-pull-request-mergeable}

Pull request mergeable event build time and status

![pr.mergeable event](//cnbprod.alpha.qq.com/svg/badge/pull_request.mergeable?message=pending%2C%2010s\&color=pending)
![pr.mergeable event](//cnbprod.alpha.qq.com/svg/badge/pull_request.mergeable?message=success%2C%2010s\&color=success)
![pr.mergeable event](//cnbprod.alpha.qq.com/svg/badge/pull_request.mergeable?message=failure%2C%2010s\&color=failure)

##### `ci/status/issue.comment@npc` {#badge-ci-status-issue-comment-npc}

Issue comment @npc event build time and status

![issue.comment@npc event](//cnbprod.alpha.qq.com/svg/badge/issue.comment%40npc?message=pending%2C%2010s\&color=pending)
![issue.comment@npc event](//cnbprod.alpha.qq.com/svg/badge/issue.comment%40npc?message=success%2C%2010s\&color=success)
![issue.comment@npc event](//cnbprod.alpha.qq.com/svg/badge/issue.comment%40npc?message=failure%2C%2010s\&color=failure)

##### `ci/status/pull_request.comment@npc` {#badge-ci-status-pull-request-comment-npc}

Pull request comment @npc event build time and status

![pr.comment@npc event][pr-comment-npc-pending]
![pr.comment@npc event][pr-comment-npc-success]
![pr.comment@npc event][pr-comment-npc-failure]

[pr-comment-npc-pending]: //cnbprod.alpha.qq.com/svg/badge/pull_request.comment%40npc?message=pending%2C%2010s&color=pending

[pr-comment-npc-success]: //cnbprod.alpha.qq.com/svg/badge/pull_request.comment%40npc?message=success%2C%2010s&color=success

[pr-comment-npc-failure]: //cnbprod.alpha.qq.com/svg/badge/pull_request.comment%40npc?message=failure%2C%2010s&color=failure

##### `ci/status/tag_push` {#badge-ci-status-tag-push}

Tag push event build time and status

![tag\_push event](//cnbprod.alpha.qq.com/svg/badge/tag_push?message=pending%2C%2010s\&color=pending)
![tag\_push event](//cnbprod.alpha.qq.com/svg/badge/tag_push?message=success%2C%2010s\&color=success)
![tag\_push event](//cnbprod.alpha.qq.com/svg/badge/tag_push?message=failure%2C%2010s\&color=failure)

#### 2. Workspace Preparation

##### `ci/git-clone-yyds` {#badge-ci-git-clone-yyds}

Workspace size and preparation time: ![git-clone-yyds
event](//cnbprod.alpha.qq.com/svg/badge/git-clone-yyds?message=2.7s%2C%20163.77%20GB\&color=success)

#### 3. Pipeline Configuration

##### `ci/pipeline-as-code` {#badge-ci-pipeline-as-code}

Cloud native build configuration file: ![pipeline-as-code
event](//cnbprod.alpha.qq.com/svg/badge/pipeline-as-code?message=.cnb.yml\&color=orange)

#### 4. Cloud Native Development

##### `code/vscode-started` {#badge-code-vscode-started}

Development environment preparation time:
![vscode-started](//cnbprod.alpha.qq.com/svg/badge/prepare-dev-env?message=22s\&color=success)

#### 5. Unit Testing

Using the built-in task [testing:coverage](../build/internal-steps/testing/coverage.md) can report unit test badge data

##### `testing/unit/coverage` {#badge-testing-unit-coverage}

Total unit test coverage

![coverage](//cnbprod.alpha.qq.com/svg/badge/coverage?message=18.67%25\&color=l2)
![coverage](//cnbprod.alpha.qq.com/svg/badge/coverage?message=38.67%25\&color=l3)
![coverage](//cnbprod.alpha.qq.com/svg/badge/coverage?message=58.67%25\&color=l4)
![coverage](//cnbprod.alpha.qq.com/svg/badge/coverage?message=78.67%25\&color=l5)

##### `testing/unit/coverage-pr` {#badge-testing-unit-coverage-pr}

Incremental unit test coverage for this pull request

![coverage-pr](//cnbprod.alpha.qq.com/svg/badge/coverage%20%40pr?message=18.67%25\&color=l2)
![coverage-pr](//cnbprod.alpha.qq.com/svg/badge/coverage%20%40pr?message=38.67%25\&color=l3)
![coverage-pr](//cnbprod.alpha.qq.com/svg/badge/coverage%20%40pr?message=58.67%25\&color=l4)
![coverage-pr](//cnbprod.alpha.qq.com/svg/badge/coverage%20%40pr?message=78.67%25\&color=l5)

#### 6. Security

##### `security/tca` {#badge-security-tca}

Tencent Cloud Code Analysis (TCA): ![tca](//cnbprod.alpha.qq.com/svg/badge/TCA?message=Fatal/Error:%204\&color=error)

#### 7. Crontab Status

##### `ci/status/crontab` {#badge-ci-status-crontab}

Crontab build duration and build status

![Crontab Event](//cnbprod.alpha.qq.com/svg/badge/crontab?message=pending%2C%2010s\&color=pending)
![Crontab Event](//cnbprod.alpha.qq.com/svg/badge/crontab?message=success%2C%2010s\&color=success)
![Crontab Event](//cnbprod.alpha.qq.com/svg/badge/crontab?message=failure%2C%2010s\&color=failure)

#### 8. Auto Merge

##### `ci/status/auto_merge` {#badge-ci-status-auto-merge}

Auto merge duration and status

![Auto merge](//cnbprod.alpha.qq.com/svg/badge/auto_merge?message=pending%2C%2010s\&color=pending)
![Auto merge](//cnbprod.alpha.qq.com/svg/badge/auto_merge?message=success%2C%2010s\&color=success)
![Auto merge](//cnbprod.alpha.qq.com/svg/badge/auto_merge?message=failure%2C%2010s\&color=failure)

## Repository Related Badges

### Fork Badge

Display repository fork count as a badge: ![fork badge](//cnbprod.alpha.qq.com/svg/badge/fork?message=18\&color=orange)

Access path: `https://cnbprod.alpha.qq.com/{group}/{repository}/-/badge/fork`

Parameter descriptions:

* `group`: Repository organization path
* `repository`: Repository name

### Star Badge

Display repository star count as a badge: ![star badge](//cnbprod.alpha.qq.com/svg/badge/star?message=20\&color=orange)

Access path: `https://cnbprod.alpha.qq.com/{group}/{repository}/-/badge/star`

Parameter meanings:

* `group`: Repository organization path
* `repository`: Repository name

### Deploy Badge

Display the latest deployment status and version of a repository environment:

* With successful deployment: ![deploy
  badge](//cnbprod.alpha.qq.com/svg/badge/Environment?message=production%3A%20v1.2.3\&color=success)
* Without deployment record: ![deploy badge](//cnbprod.alpha.qq.com/svg/badge/Environment?message=production\&color=orange)

Access path: `https://cnbprod.alpha.qq.com/{group}/{repository}/-/badge/deploy?name={name}`

Click-through path: `https://cnbprod.alpha.qq.com/{group}/{repository}/-/badge/deploy.link?name={name}`

Parameter descriptions:

* `group`: Repository organization path
* `repository`: Repository name
* `name`: Deployment environment name (required), e.g., `production`, `staging`, etc.

### Release Badge

Display the latest Release version of the repository.
If a Release tag has been manually set as the Latest Release,
the badge prioritizes that Release; otherwise, it defaults to the most recently created Release:

* With Release: ![release badge](//cnbprod.alpha.qq.com/svg/badge/Latest%20Release?message=v1.2.3\&color=success)
* Without Release: ![release badge](//cnbprod.alpha.qq.com/svg/badge/Latest%20Release?message=none\&color=orange)

Access path: `https://cnbprod.alpha.qq.com/{group}/{repository}/-/badge/release`

Click-through path: `https://cnbprod.alpha.qq.com/{group}/{repository}/-/badge/release.link`

Parameter descriptions:

* `group`: Repository organization path
* `repository`: Repository name

## Using Badges in Markdown

Two formats are supported for embedding badges as images in Markdown:

With domain and repository:
`![Full path badge](https://cnbprod.alpha.qq.com/groupname/reponame/-/badge/git/latest/ci/git-clone-yyds)`

Without domain and repository: paths starting with `/-/badge/git` will be recognized as badges:
`![Relative path badge](/-/badge/git/latest/ci/git-clone-yyds)`
