logo
11
3
WeChat Login

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

About

用 Open Api 触发流水线

example
Language
JavaScript73.1%
Dockerfile26.9%