logo
10
3
Login
docs: 去掉太长的示例,只保留简单的

API Trigger Pipeline Example

badge badge

SAAS version API endpoint: trigger build

Example implementation: index.js

Note

This example demonstrates how to trigger a pipeline via API from outside the CNB system.

If you need to trigger directly in .cnb.yml, we recommend using the official task cnb:trigger.

How to Use

node

Copy the .cnb.yml content and index.js file to your CNB project for direct usage (requires Node.js to run index.js).

bash

# Trigger predefined pipeline in .cnb.yml with custom environment variables curl -X POST \ -H "Content-Type: application/json" \ -H "Authorization: Bearer $CNB_TOKEN" \ -d '{ "event": "api_trigger_in_cnb", "env": { "ENV_PAASD": "env value 1" } }' \ $CNB_API_ENDPOINT/$CNB_REPO_SLUG/-/build/start