Transformer

Transform information before using it

Description

The parameter "transformers" can be used by any stage definitions as "source", "condition", or "target". A "transformers" contains a list of transformer. Each kind transformer rule apply a string manipulation like adding or removing characters. Depending on the stage, a "transformers" block achieves different objectives.

source

Source returns information modified by a list of transformers

condition

A condition receives information from the source then modifies that value using transformers before using it in the resource.

target

A target receives information from the source then modifies that value with the transformers rule before using the resource.

Parameters

Name

Default

Description

replacer

-

Replace a string with another one, more here

replacers

-

A list of Replacer

addPrefix

-

Add prefix to the value

addSuffix

-

Add suffix to the value

trimPrefix

-

Remove prefix to the value

trimSuffix

-

Remove suffix to the value

find

-

Search for a string value using regular expression and then return its value exist

findSubMatch

-

Search for a substring using regular expression and then return its content, more here

semverInc

-

Bump semantic version, accept a comma separated list of ["major","minor","patch"]

Replacer

A replacer rule modifies the information by replacing the "from" value by the "to" value.

NameRequiredDefaultDescription

from

-

"from" value defines the string that will be replaced

to

-

"to" value defines the string that we want to have

FindSubMatch

A findSubMatch rule captures the desired information by applying "pattern" as a regexp and using "captureIndex" value as the index for the capture to return (default 0).

NameRequiredDefaultDescription

pattern

-

"pattern" value defines the regular expression to apply

captureIndex

-

-

"captureIndex" value defines the index of the capture to return. Note that the default value 0 returns all submatches, and individual submatch indexes start at 1.

Example

The findSubmatch below will return the submatch captured with (.*?):

updatecli.yaml
sources:
  default:
    name: "Get latest jenkins weekly version"
    kind: jenkins
    transformers:
      - addPrefix: "alpha-"
      - addSuffix: "-jdk11"
      - trimSuffix: "-jdk11"
      - trimPrefix: "alpha-"
      - replacer:
          from: "-jdk11"
          to: "-jdk15"
      - replacers:
          - from: "-jdk15"
            to: "-jdk17"
      - findsubmatch:
          pattern: '"(.*?):(.*)'
          captureIndex: 1
      - semverInc: "major,minor"
      - find: "2.234.(.*)$"
    spec:
      release: weekly
targets:
  targetID:
    name: "Update file file"
    kind: file
    spec:
      file: TODO

Edit this page on GitHub