---
url: /zh/build/internal-steps/cnb/destroy-token.md
---
`cnb:destroy-token`

流水线启动前自动创建 [CNB\_TOKEN](../../build-in-env.md#cnb_token)，
结束后自动销毁。使用该任务可提前销毁 CNB\_TOKEN 并移除对应环境变量。

* [适用事件](#cnb-destroy-token-applicable-events)
* [参数](#cnb-destroy-token-parameters)
* [输出结果](#cnb-destroy-token-output)
* [配置样例](#cnb-destroy-token-configuration-examples)

## 适用事件 {#cnb-destroy-token-applicable-events}

[所有事件](../../trigger-rule.md#trigger-event)

## 参数 {#cnb-destroy-token-parameters}

无

## 输出结果 {#cnb-destroy-token-output}

无

## 配置样例 {#cnb-destroy-token-configuration-examples}

流水线中使用 CNB\_TOKEN 后主动销毁，降低令牌滥用风险。

```yaml title=".cnb.yml"
main:
  push:
    - stages:
        - name: use CNB_TOKEN
          script: echo "Make API calls using the CNB_TOKEN."
        - name: destroy token
          type: cnb:destroy-token
```
