SAAS version API endpoint: trigger build
Example implementation: index.js
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.
Copy the .cnb.yml content and index.js file to your CNB project for direct usage (requires Node.js to run index.js).
# 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