---
url: /en/develops/badge.md
---
Badges are used to display metric data and can distinguish whether metrics meet standards through different colors.

## Cloud Native Build Related Badges

### Badge Access Path

Badges generated during cloud native builds can be accessed via:

* precise: `https://cnb.build/{group}/{repository}/-/badge/git/{sha}/{metrics}`

* latest: `https://cnb.build/{group}/{repository}/-/badge/git/latest/{metrics}`

* branch latest: `https://cnb.build/{group}/{repository}/-/badge/git/latest/{metrics}?branch={branch}`

* Parameter meanings:
  * `group`: The repository's group
  * `repository`: Repository name
  * `sha`: First 8 characters of the CommitId
  * `latest`: When the branch parameter is not specified, fetch the badge for the latest commit on the default branch; when the branch parameter is specified, fetch the badge corresponding to the latest commit hash of the specified branch.
  * `metrics`: Metric name, e.g., `ci/status/push`, which represents: build time triggered by push event during cloud native build
  * `branch`: The branch name, such as `main`, takes effect only when the SHA is set to `latest`. In this case, the badge corresponding to the latest commit hash of the current branch will be fetched.

### Badge Types

During cloud native builds, badge data for relevant build metrics will be automatically uploaded:

#### 1. Git Events

* ci/status/push

Push event build time and build status

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

* ci/status/commit.add

Push event build time and build status

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

* ci/status/branch.create

Branch create event build time and build status

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

* ci/status/pull\_request

Pull request event build time and build status

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

* ci/status/pull\_request.update

Pull request update event build time and build status

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

* ci/status/pull\_request.target

Pull request target event build time and build status

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

* ci/status/pull\_request.merged

Pull request merged event build time and build status

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

* ci/status/tag\_push

Tag push event build time and build status

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

#### 2. Workspace Preparation

* ci/git-clone-yyds

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

#### 3. Pipeline Configuration

* ci/pipeline-as-code

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

#### 4. Cloud Native Development

* code/vscode-started

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

#### 5. Unit Testing

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

* testing/unit/coverage

Total unit test coverage

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

* testing/unit/coverage-pr

Incremental unit test coverage for this pull request

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

#### 6. Security

* security/tca

Tencent cloud code analysis(TCA)：![tca](//cnb.build/svg/badge/TCA?message=Fatal/Error:%204\&color=error)

#### 7. Crontab Status

* ci/status/crontab

Crontab build duration and build status

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

## Repository Related Badges

### Fork Badge

Display repository fork count in badge form: ![fork badge](//cnb.build/svg/badge/fork?message=18\&color=orange)

Access path: `https://cnb.build/{group}/{repository}/-/badge/fork`

Parameter meanings:

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

### Star Badge

Display repository star count in badge form: ![star badge](//cnb.build/svg/badge/star?message=20\&color=orange)

Access path: `https://cnb.build/{group}/{repository}/-/badge/star`

Parameter meanings:

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

## Using Badges in Markdown

The following two formats are supported for using badges as images in markdown:

With domain and repository: `![Full path badge](https://cnb.build/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)`
