apply
cnb:apply
Specify the configuration file, bind it to the current Git
repository, and execute the specified event pipeline.
# Applicable Events
push
branch.create
pull_request.target
pull_request.mergeable
tag_push
pull_request.merged
api_trigger
web_trigger
crontab
tag_deploy
# Parameters
# config
- type:
String
- required:
false
The complete content of the CI
configuration file
# configFrom
- type:
String
- required:
false
Specify a local file as the configuration file.
# event
- type:
String
- required:
false
- default:
api_trigger
The custom event name to be executed must be either api_trigger
or start with api_trigger_
.
# sync
- type:
Boolean
- required:
false
- default:
false
Whether to execute synchronously.
In synchronous mode, it waits for the current apply
pipeline to execute successfully before proceeding to the next task.
# continueOnBuildError
- type:
Boolean
- required:
false
- default:
false
In synchronous mode, should the execution of the next task continue when the triggered pipeline build fails?
# ignoreGitStatus
- type:
Boolean
- required:
false
- default:
false
Whether to ignore the git status
setting.
After ignoring it, the pipeline will not appear in the "commit checks".
# title
- type:
String
- required:
false
Custom Pipeline Title
# Environment Variables
All business-defined environment variables visible to the current job are passed to the new pipeline.
The following environment variables are included in the default values, which cannot be overridden by users:
APPLY_TRIGGER_BUILD_ID
, with the same meaning as theCNB_BUILD_ID
environment variable in CIAPPLY_TRIGGER_PIPELINE_ID
, with the same meaning as theCNB_PIPELINE_ID
environment variable in CIAPPLY_TRIGGER_REPO_SLUG
, with the same meaning as theCNB_REPO_SLUG
environment variable in CIAPPLY_TRIGGER_REPO_ID
, with the same meaning as theCNB_REPO_ID
environment variable in CIAPPLY_TRIGGER_USER
, with the same meaning as theCNB_BUILD_USER
environment variable in CIAPPLY_TRIGGER_BRANCH
, with the same meaning as theCNB_BRANCH
environment variable in CIAPPLY_TRIGGER_COMMIT
, with the same meaning as theCNB_COMMIT
environment variable in CIAPPLY_TRIGGER_COMMIT_SHORT
, with the same meaning as theCNB_COMMIT_SHORT
environment variable in CIAPPLY_TRIGGER_ORIGIN_EVENT
, with the same meaning as theCNB_EVENT
environment variable in CICNB_PULL_REQUEST_ID
, with the same meaning as theCNB_PULL_REQUEST_ID
environment variable in CICNB_PULL_REQUEST_IID
, with the same meaning as theCNB_PULL_REQUEST_IID
environment variable in CICNB_PULL_REQUEST_MERGE_SHA
, with the same meaning as theCNB_PULL_REQUEST_MERGE_SHA
environment variable in CI
# Configuration Value Priority
The configuration values are retrieved in the following order until a value is found:
config
configFrom
- Current repository's
.cnb.yml
file- If the
apply
built-in task is called within thepull_request.merged
event, the merged configuration file is used. - If the
apply
built-in task is called within thepull_request.target
orpull_request.mergeable
events, the configuration file from the target branch is used. - In other cases, the configuration file from the current branch is used.
- If the
Note that configFrom
only supports local files such as ./test/.cnb.yml
. For remote files,
you need to download them locally beforehand.
# 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 is successful, this key only exists in synchronous mode
"lastJobExports": {} // Environment variables exported by the last job in the triggered pipeline
}
# Configuration Examples
main:
push:
- stages:
- name: trigger
type: cnb:apply
options:
configFrom: ./test/.cnb.yml
event: api_trigger_test
main:
push:
- stages:
- name: trigger
type: cnb:apply
options:
config: |
main:
api_trigger_test:
- stages:
- name: test
script: echo test
event: api_trigger_test
main:
push:
- stages:
- name: trigger
type: cnb:apply
options:
# Execute other events defined in the current configuration file
event: api_trigger_test
api_trigger_test:
- stages:
- name: test
script: echo test
main:
push:
- stages:
- name: trigger
type: cnb:apply
options:
configFrom: .xxx.yml
event: api_trigger_get_alpha
sync: true