runabol / piper

piper - a distributed workflow engine
Apache License 2.0
489 stars 86 forks source link

Switch not working as per document #36

Open bappctl opened 5 years ago

bappctl commented 5 years ago

Issue: Switch/Cases never executes "default" block.

Created below pipeline. On executing Switch Cases, when "year" value is not 2019 or 2020 it NEVER reaches Default block to set respective value to "output" variable, and the coordinator status always comes FAILED

2019-05-03 22:27:28.001 DEBUG 20812 --- [cTaskExecutor-1] c.c.piper.core.event.LogEventListener : {jobId=a9cabddd12f3469d9c68505fc7da6428, createTime=2019-05-04T05:27:27.993+0000, id=5097b47a74204e38af03b181fdd1cd9b, type=job.status, status=FAILED}

Request:

{ "pipelineId":"myswitch", "inputs": { "year":"2019" } }

Response:

{ "createTime": "2019-05-04T05:27:27.490+0000", "webhooks": [], "inputs": { "year": "2090" }, "id": "a9cabddd12f3469d9c68505fc7da6428", "label": "Switch", "priority": 0, "pipelineId": "switch2", "status": "CREATED", "tags": [] }

switch2.yaml

label: Switch

inputs:
  - name: year
    type: string
    required: true

tasks:          

  - name: selector
    type: var
    value: ${year}

  - type: switch
    expression: ${selector}
    cases: 
      - key: "2019"
        tasks: 
          - name: output
            type: var
            value: Requested this year ${selector} schedule 
      - key: "2020"
        tasks: 
          - name: output
            type: var
            value: Requested next year ${selector} schedule 
    default: 
          -  name: output
             type: var
             value: Schedule not available for year ${selector}

  - type: print
    label: ${selector}-${output}
    text: ${output}