How to create valid and meaningful forms for your pipelines
Extend the built-in Pipeline feature with PFO fields in 3 steps:
Create fields
Add fields to forms
Connect forms with pipelines
4. (Optional) - Group fields into presets - prefill fields and create variations
5. (Optional) - Validate form before a commit - with the online validator
Creating fields
Fields and forms can be added by editing the pipeline-forms.yml,which is a custom file you have to create in addition to having thebitbucket-pipelines.yml.
This is a basic example for creating a text and a select field with some options.
fields: - &example-text-fieldlabel:Text fieldtype:textname:TEST_TEXT_FIELDdefaultValue:I am a test - &mandatory-text-field<<:*example-text-fieldmandatory:true - &example-select-fieldlabel:Select fieldtype:selectname:TEST_SELECT_FIELDnote:"Select any value from below list"defaultValue:OneavailableValues: - One - Two - Three
You can also use the characters '<<:' to add more values to previously defined fields.
Available attributes
Keys and values can be selected from the following set:
* = required
**= required where aplicable
Available field types
In PFO you can extend your pipelines with the following field types while editing the pipeline-forms.yml:
When adding a field right at the forms you don't need to use the anchor.
*When using remote select, the specified URL must point to a publicly accessible endpoint which must give a JSON formatted response body. The path must be specified as a JSON Path, which you can experiment with using the https://jsonpath.com/ tool.
Building forms
Fields need to be added to the pipeline-forms.yml first, then they can be added to forms. Forms will be rendered on the UI when selected.
fields: - &example-text-fieldlabel:Text fieldtype:textname:EXAMPLE_TEXT_FIELDdefaultValue:I am a testmandatory:trueregex:.* - &example-select-fieldlabel:Select fieldtype:selectname:EXAMPLE_SELECT_FIELDnote:"Select any value from below list"defaultValue:Select 1availableValues: - Select 1 - Select 2 - Select 3 - &example-radio-fieldlabel:Radio fieldtype:radioname:EXAMPLE_RADIO_FIELDavailableValues: - Radio 1 - Radio 2forms: - name:Small form with radiofields: - *example-text-field - *example-radio-fieldpipeline:testgroups: - TEST_GROUP - JIRA - name:Small form with selectfields: - *example-text-field - *example-select-fieldgroups: - JIRApipeline:test - name:Big form without groupfields: - *example-text-field - *example-radio-field - *example-select-fieldpipeline:test2
Presets (Groups)
If you want a field or form similar to an existing one but with different default values you don't have to copy the whole object, just use the power of YAML Anchors. This way you can reference an existing object and override only some of its properties.
fields: - &example-text-fieldlabel:Text fieldtype:textname:EXAMPLE_TEXT_FIELDdefaultValue:I am a testmandatory:trueregex:.* - &example-select-fieldlabel:Select fieldtype:selectname:EXAMPLE_SELECT_FIELDnote:"Select any value from below list"defaultValue:Select 1availableValues: - Select 1 - Select 2 - Select 3 - &example-radio-fieldlabel:Radio fieldtype:radioname:EXAMPLE_RADIO_FIELDavailableValues: - Radio 1 - Radio 2forms: - name:Small form with radiofields: - *example-text-field - *example-radio-fieldpipeline:testgroups: - TEST_GROUP - JIRA - name:Small form with selectfields: - *example-text-field - *example-select-fieldgroups: - JIRApipeline:test - name:Big form without groupfields: - *example-text-field - <<:*example-text-fielddefaultValues:Text field valuereadonly:true - *example-radio-field - *example-select-fieldpipeline:test2
The value can be referred from the configuration as an ID.
note
description for the fields
Will be visible under the field as a helper text.
defaultValue
predefined value
The value will be added by default on the form.
mandatory
true value makes the field required
The field can not be empty when submitting.
availableValues**
can be added at fields with a fix set of values
When values can be selected from a strict list.
secure
true value makes the field hidden
Password and other secret values that should not be shared (even viewed) after inserting.
hidden
true value makes the field not showing on the form
Make a field prefilled in the background, without the possibility to change the value. Like a hard coded variable.
readonly
true value makes the field visible on the form, but default value can not be overwritten
Make a field prefilled, but show on the form to let the user know. This is useful while using presets, to fill and protect several fields in advance.
regex
a regular expression pattern to validate the input value
Use this property to enforce a specific format or pattern for user input. The input value must match the provided regular expression for successful validation.
Select
secure
mandatory
note
readonly
defaultValue
availableValues
Remote Select*
secure
mandatory
note
readonly
availableValues
url
path
Text
secure
mandatory
note
readonly
defaultValue
regex
hidden
Textarea
secure
mandatory
note
readonly
defaultValue
regex
hidden
Number
secure
mandatory
note
readonly
defaultValue
regex
Checkbox (single select)
secure
mandatory
note
readonly
defaultValue
true | false
Checkbox group (multi-select)
secure
mandatory
note
readonly
availableValues
Radio button
secure
mandatory
note
readonly
defaultValue
availableValues
Date
secure
mandatory
note
readonly
defaultValue
Format: yyyy-mm-dd
- &select-examplelabel:Select fieldtype:selectname:TEST_SELECT_FIELDdefaultValue:OneavailableValues: - One - Two - Three