Manually Trigger Pipeline
About 965 wordsAbout 3 min
Cloud Native Build supports configuring custom buttons on the page to trigger pipeline execution by clicking (only supports triggering web custom events). It also supports inputting environment variables on the page.
The effect is as follows:

Tips
Currently, custom buttons can only be configured on the Code-Branch Details Page
.
Custom Button Configuration
Add a .cnb/web_trigger.yml
file in the repository root directory to configure custom buttons. Note that the .cnb/web_trigger.yml
configuration file does not support include
and imports
syntax.
# .cnb/web_trigger.yml
branch:
# The following buttons are displayed on the branch details page where the branch name starts with release
- reg: "^release"
buttons:
- name: Button Name 1
# If exists, it will be used as the pipeline title, otherwise the pipeline will use the default title
description: Button Description
event: web_trigger_one # CI event name to trigger
# Permission control, if not configured, users with repository write permission can trigger the build
# If configured, repository write permission is required, and either roles or users must be satisfied to have permission to trigger the build
permissions:
# Configure either roles or users or both, satisfying either one is sufficient
roles:
- owner
- developer
users:
- name1
- name2
# Environment variables
env:
# Default environment variables, where key values (a,b,c) are environment variable names, supporting the following two formats
a: 1
b: 2
c:
# Environment variable alias
name: Variable c
# Environment variable value
value: 3
# Input environment variables, can override the above env variable configuration
inputs:
# Currently supports three formats: input box (input), multi-line text input box (textarea), dropdown selection box (select supports single and multiple selection), switch
# Where key values (var1, var2, var3, var4, var5) are environment variable names
var1:
# Input box
name: Variable 1
description: Input Variable 1
required: true # Whether required
type: input
default: Default Value 1
var2:
# Text area
name: Variable 2
description: Input Variable 2
required: true
type: textarea
default: Default Value 2
var3:
# Single-select dropdown
name: Variable 3
description: Input Variable 3
required: false
type: select
default: value1
options:
- name: Option 1
value: value1
description: Option 1 Description
- name: Option 2
value: value2
description: Option 2 Description
var4:
# Multi-select dropdown
name: Variable 4
description: Input Variable 4
required: false
type: select
# Whether to support multiple selection, multiple results are separated by semicolons
multiple: true
default: value1,value2
options:
- name: Option 1
value: value1
description: Option 1 Description
- name: Option 2
value: value2
description: Option 2 Description
- name: Option 3
value: value3
description: Option 3 Description
var5:
# Switch
name: Variable 5
description: Select Variable 5
required: false
type: switch
default: value1
options:
- name: Option 1
value: value1
description: Option 1 Description
- name: Option 2
value: value2
description: Option 2 Description
# The following buttons are displayed on the branch details page where the branch name starts with dev
- reg: "^dev"
buttons:
- name: Button Name 2
description: Button Description
event: web_trigger_two
- name: Button Name 3
description: Button Description
event: web_trigger_three
# The following custom buttons are displayed on all branch details pages
- buttons:
- name: Button Name 4
description: Button Description
event: web_trigger_four
Currently, only custom buttons on the branch details page are supported. The key in yaml is branch
, and the value is in array format. The array elements are defined as follows:
reg
: Optional,String
, regular expression used to match branch names (only matched branches display custom buttons configured inbuttons
), if not filled, matches all branchesbuttons
: Required,Array<Button>
, custom button definition.Button
type is defined as followsname
: Required,String
, custom button namedescription
: Optional,String
, button description. If exists, it will be used as the pipeline title, otherwise the pipeline will use the default titleevent
: Required,String
, event nameenv
: Optional,Object<String, String|EnvType>
, default environment variables passed to the web_trigger custom event pipeline, not editable. Object key is the environment variable name; Object value supports two formats,String
andEnvType
.EnvType
type is defined as follows:name
: Required,String
, environment variable alias. Not the environment variable name passed to the pipelinevalue
: Required,String
, environment variable value
permissions
: Optional, permission control, satisfying eitherusers
orroles
grants permission to trigger the build (repository write permission is also required). Ifpermissions
is not configured, repository write permission is sufficient to trigger the buildusers
: Optional,Array<String>
, username array. Multiple can be defined.roles
: Optional,Array<String>
, repository role array. Multiple repository roles can be defined.owner
,master
(Administrator),developer
,reporter
,guest
inputs
: Optional,Object<String, Input>
, manually input environment variables, object key is the variable name,Input
type is defined as follows:description
: Optional,String
, descriptionrequired
: Optional,Boolean
, whether requiredtype
: Optional,String
, input type, can beinput
,textarea
,select
,switch
, default isinput
default
: Optional,String
, default valuemultiple
: Optional,Boolean
, whether to support multiple selection, only valid when type=select
, multiple results are separated by semicolons. Commas should be avoided in thevalue
of individual optionsoptions
: Optional,Array<Option>
, options whentype: select
ortype: switch
.Option
type is defined as follows:name
: Required,String
, option namevalue
: Required,String
, option value, used as environment variable valuedescription
: Optional,String
, option description
Custom web_trigger Pipeline
The custom buttons in .cnb/web_trigger.yml
only support triggering web_trigger events.
The web_trigger
event pipeline is configured in .cnb.yml
# .cnb.yml
# Match branch names starting with release
release*:
# Events that can be triggered by custom buttons
web_trigger_one:
- stages:
- name: Output Environment Variables
script:
- echo $a
- echo $b
- echo $var1
- echo $var2
- echo $var3
# Match branch names starting with dev
dev*:
web_trigger_two:
- stages:
- name: Execute Task
script: echo "job"
web_trigger_three:
- stages:
- name: Execute Task
script: echo "job"
# Match all branch names
"**":
web_trigger_four:
- stages:
- name: Execute Task
script: echo "job"
Permission Description
Only users with repository write permission
can click custom buttons to execute web_trigger
pipelines.