♟️Syntax for the pipeline-forms.yml file

How to create valid and meaningful forms for your pipelines

Extend the built-in Pipeline feature with PFO fields in 3 steps:

  1. Create fields

  2. Add fields to forms

  3. 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-field
    label: Text field
    type: text
    name: TEST_TEXT_FIELD
    defaultValue: I am a test
  - &mandatory-text-field
    <<: *example-text-field
    mandatory: true
  - &example-select-field
    label: Select field
    type: select
    name: TEST_SELECT_FIELD
    note: "Select any value from below list"
    defaultValue: One
    availableValues:
      - 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-field
    label: Text field
    type: text
    name: EXAMPLE_TEXT_FIELD
    defaultValue: I am a test
    mandatory: true
    regex: .*
  - &example-select-field
    label: Select field
    type: select
    name: EXAMPLE_SELECT_FIELD
    note: "Select any value from below list"
    defaultValue: Select 1
    availableValues:
      - Select 1
      - Select 2
      - Select 3
  - &example-radio-field
    label: Radio field
    type: radio
    name: EXAMPLE_RADIO_FIELD
    availableValues:
      - Radio 1
      - Radio 2
forms:
  - name: Small form with radio
    fields:
      - *example-text-field
      - *example-radio-field
    pipeline: test
    groups:
      - TEST_GROUP
      - JIRA
  - name: Small form with select
    fields:
      - *example-text-field
      - *example-select-field
    groups:
      - JIRA
    pipeline: test
  - name: Big form without group
    fields:
      - *example-text-field
      - *example-radio-field
      - *example-select-field
    pipeline: 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-field
    label: Text field
    type: text
    name: EXAMPLE_TEXT_FIELD
    defaultValue: I am a test
    mandatory: true
    regex: .*
  - &example-select-field
    label: Select field
    type: select
    name: EXAMPLE_SELECT_FIELD
    note: "Select any value from below list"
    defaultValue: Select 1
    availableValues:
      - Select 1
      - Select 2
      - Select 3
  - &example-radio-field
    label: Radio field
    type: radio
    name: EXAMPLE_RADIO_FIELD
    availableValues:
      - Radio 1
      - Radio 2
forms:
  - name: Small form with radio
    fields:
      - *example-text-field
      - *example-radio-field
    pipeline: test
    groups:
      - TEST_GROUP
      - JIRA
  - name: Small form with select
    fields:
      - *example-text-field
      - *example-select-field
    groups:
      - JIRA
    pipeline: test
  - name: Big form without group
    fields:
      - *example-text-field
      - <<: *example-text-field
        defaultValues: Text field value
        readonly: true
      - *example-radio-field
      - *example-select-field
    pipeline: test2

Last updated