Matrix - Examples

JFrog Pipelines Documentation

ft:sourceType
Paligo

The following examples show how to configure a Matrix step. For more information about Matrix Pipeline steps, see Matrix

Example 1

This is an example of how to use the Matrix step to perform a build activity.

Matrix Step Example

pipelines:
  - name: myPipeline
    steps:
      - name: matrix_example
        type: Matrix
        stepMode: Bash
        configuration:
            multiNode: true
        stepletMultipliers:
          environmentVariables:             # Sets of environment variables for steplets
            - animal:    dog                            # - Set 1
              mineral:   copper
              vegetable: carrot
            - animal:    goat                           # - Set 2
              mineral:   iron
              vegetable: broccoli
            - animal:    lizard             # - Set 3
              mineral:   lead        

          nodePools:
                - gcp
                - aws 
          
          runtimes:                         # Runtimes for steplets
            - type: image
              image:
                auto:
                  language: java
                  versions:
                    - 13.0
            - type: image
              image:
                auto:
                  language: node
                  versions:
                    - 8.17.0
        execution:
          onExecute:
            - echo "I am executing matrix steplet ${steplet_id}"
            - echo "Envs animal= $animal , mineral = $mineral , vegetable = $vegetable"
            - echo "Runtime image name:$step_image_name | Runtime image tag:$step_image_tag"

When run, the above example will execute in a total of 6 steplets: in 2 runtimes for each of 3 sets of environment variables:

Runtime

Set 1

Set 2

Set 3

java 13.0

dog, copper, carrrot

goat, iron, broccoli

lizard, lead, <null>

node 8.17.0

dog, copper, carrrot

goat, iron, broccoli

lizard, lead, <null>

Example 2 - allowFailures, Exclude, fastFail

pipelines:
  - name: S_Matrix_0052
    steps:           
      - name: S_Matrix_0052
        type: Matrix
        stepMode: Bash
        stepletMultipliers:
          fastFail: true
          allowFailures:
            - environmentVariables:
                delay: 1
                fail: 'true'
            - environmentVariables:
                delay: 1
                fail: 'true'
          exclude:
            - environmentVariables:
                delay: 1
                fail: 'true'
            - environmentVariables:
                delay: 1
                fail: 'true'
          environmentVariables:
            - delay: 1
              fail: 'true'
            - delay: 2
              fail: 'false'
            - delay: 3
              fail: 'false'
            - delay: 5
              fail: 'false' 
        execution:
          onStart:
            - sleep "$delay"
          onExecute:
            - echo "This is a matrix step"
            - |
              [ $fail == 'false' ] 
            - ls -l .

Example 3 - concurrency

pipelines:
  - name: matrix_check
    steps:
      - name: step1
        type: Matrix
        stepMode: Bash
        configuration: 
          concurrency: 50
        stepletMultipliers:
          environmentVariables:            # Sets of environment variables for steplets
          - animal:    dog                 # - Set 1
            mineral:   copper
            vegetable: carrot
          - animal:    goat                # - Set 2
            mineral:   iron
            vegetable: broccoli
          - animal:    lizar1d             # - Set 3
            mineral:   lea1d
          - animal:    liza2rd             # - Set 3
            mineral:   le2ad  
          - animal:    liza3rd             # - Set 3
            mineral:   lea3d
          - animal:    liza4rd             # - Set 3
            mineral:   lea4d
          - animal:    liza5rd             # - Set 3
            mineral:   le5ad  
          - animal:    liz6ard             # - Set 3
            mineral:   lea6d  
          - animal:    lizar7d             # - Set 3
            mineral:   le7ad  
          - animal:    lizar8d             # - Set 3
            mineral:   lea8d 
          - animal:    liza9rd             # - Set 3
            mineral:   lea9d 
          - animal:    liza10rd            # - Set 3
            mineral:   lead10 
          - animal:    liza11rd            # - Set 3
            mineral:   lead11  
          - animal:    liza12rd            # - Set 3
            mineral:   lead12  
          - animal:    lizar13d            # - Set 3
            mineral:   lead13
          - animal:    d1og14              # - Set 1
            mineral:   copper14
            vegetable: carrot14
          - animal:    go1at15             # - Set 2
            mineral:   ir1on15
            vegetable: broccoli15
          - animal:    lizard16            # - Set 3
            mineral:   lead16
          - animal:    lizard17            # - Set 3
            mineral:   lead17
          - animal:    lizard18            # - Set 3
            mineral:   lead18
          - animal:    lizard19            # - Set 3
            mineral:   lead20
          - animal:    lizard20            # - Set 3
            mineral:   lead20
          - animal:    lizard21            # - Set 3
            mineral:   lead21
          - animal:    lizard22            # - Set 3
            mineral:   lead22
          - animal:    lizard23            # - Set 3
            mineral:   lead23
          - animal:    lizard24            # - Set 3
            mineral:   lead24
          - animal:    lizard25            # - Set 3
            mineral:   lead25 
          - animal:    lizard26            # - Set 3
            mineral:   lead26
          - animal:    lizard27            # - Set 3
            mineral:   lead27
          - animal:    lizard28            # - Set 3
            mineral:   lead28
          - animal:    dog29               # - Set 1
            mineral:   copper29
            vegetable: carrot29
          - animal:    goat30              # - Set 2
            mineral:   iron30
            vegetable: broccoli30
          - animal:    lizard31            # - Set 3
            mineral:   lead31
          - animal:    lizard32            # - Set 3
            mineral:   lead32  
          - animal:    lizard33            # - Set 3
            mineral:   lead33
          - animal:    lizard34            # - Set 3
            mineral:   lead34
          - animal:    lizard35            # - Set 3
            mineral:   lead35  
          - animal:    lizard36            # - Set 3
            mineral:   lead36  
          - animal:    lizard37            # - Set 3
            mineral:   lead37  
          - animal:    lizard38            # - Set 3
            mineral:   lead38
          - animal:    lizard39            # - Set 3
            mineral:   lead39
          - animal:    lizard40            # - Set 3
            mineral:   lead40  
          - animal:    lizard41            # - Set 3
            mineral:   lead41  
          - animal:    lizard42            # - Set 3
            mineral:   lead42
          - animal:    lizard43            # - Set 3
            mineral:   lead43     
          - animal:    dog44               # - Set 1
            mineral:   copper44
            vegetable: carrot44
          - animal:    goat45              # - Set 2
            mineral:   iron45
            vegetable: broccoli45
          - animal:    lizard46            # - Set 3
            mineral:   lead46
          - animal:    lizard47            # - Set 3
            mineral:   lead47  
          - animal:    lizard48            # - Set 3
            mineral:   lead48
          - animal:    lizard49            # - Set 3
            mineral:   lead49
          - animal:    lizard50            # - Set 3
            mineral:   lead50
 
        execution:
          onExecute:
            - echo "I am executing matrix steplet ${steplet_id}"
            - echo "Envs animal= $animal , mineral = $mineral , vegetable = $vegetable