trigger
cnb:trigger
Trigger a custom event pipeline in another repository within the current repository.
# Applicable Events
# Parameters
# token
- type:
String
- required:
true
Personal Access Token.
The new pipeline trigger will be initiated by the user corresponding to the token, and it will check for the permissions of the target repository.
# slug
- type:
String
- required:
true
The full path of the target repository, for example: group/repo
.
# event
- type:
String
- required:
true
The custom event name for triggering must be either api_trigger
or start with api_trigger_
.
In order to trigger the pipeline, the target repository must have a pipeline configured for the corresponding event.
# branch
- type:
String
- required:
false
Trigger branch, defaulting to the main branch.
# sha
- type:
String
- required:
false
CommitId in the trigger branch, defaulting to the latest commit record of the branch
.
# env
- type: TriggerEnv
- required:
false
The environment variables when triggering the pipeline in the target repository.
The default values include the following environment variables that cannot be overridden by the user:
API_TRIGGER_BUILD_ID
,It has the same meaning as theCNB_BUILD_ID
environment variable in the default CI environment variables.API_TRIGGER_PIPELINE_ID
,It has the same meaning as theCNB_PIPELINE_ID
environment variable in the default CI environment variables.API_TRIGGER_REPO_SLUG
,It has the same meaning as theCNB_REPO_SLUG
environment variable in the default CI environment variables.API_TRIGGER_REPO_ID
,It has the same meaning as theCNB_REPO_ID
environment variable in the default CI environment variables.API_TRIGGER_USER
,It has the same meaning as theCNB_BUILD_USER
environment variable in the default CI environment variables.API_TRIGGER_BRANCH
,It has the same meaning as theCNB_BRANCH
environment variable in the default CI environment variables.API_TRIGGER_COMMIT
,It has the same meaning as theCNB_COMMIT
environment variable in the default CI environment variables.API_TRIGGER_COMMIT_SHORT
,It has the same meaning as theCNB_COMMIT_SHORT
environment variable in the default CI environment variables.
# sync
- type:
Boolean
- required:
false
- default:
false
Is it executed synchronously? In synchronous mode, it will wait for the current trigger
pipeline to be executed successfully before proceeding to the next task.
# continueOnBuildError
- type:
Boolean
- required:
false
- default:
false
In synchronous mode, when the triggered pipeline build fails, does it continue executing the next task?
# title
- type:
String
- required:
false
Custom Pipeline Title
Schema Definition
TriggerEnv
{
[key: String
]: String
| Number
| Boolean
}
# Output Results
{
"sn": "cnb-i5o-1ht8e12hi", // Build number
"buildLogUrl": "http://xxx/my-group/my-repo/-/build/logs/cnb-i5o-1ht8e12hi", // Build log URL
"message": "success",
"buildSuccess": true, // Whether the triggered build was successful, this key only exists in synchronous mode
"lastJobExports": {} // Environment variables exported by the last job in the triggered pipeline
}
# Configuration Example
# Basic Usage
Trigger a pipeline with the event name api_trigger_test
in the main
branch of the repository a/b
from the current repository.
The configuration file for the triggered pipeline uses the .cnb.yml
file in the main
branch of the repository.
Check if the user has repository permissions using the access token $TOKEN
.
main:
push:
- stages:
- name: trigger
type: cnb:trigger
imports: https://xxx/envs.yml
options:
token: $TOKEN
slug: a/b
branch: main
event: api_trigger_test