argoproj / argo-events

Event-driven Automation Framework for Kubernetes
https://argoproj.github.io/argo-events/
Apache License 2.0
2.37k stars 738 forks source link

Conditionals "when" not working #199

Closed emichaf closed 5 years ago

emichaf commented 5 years ago

Trying the conditional "when" based on global var {{workflow.parameters.gerritevent}}, but the steps with "when" is never executed and the work flow doesn't excecute the onExit: exit-handler either!

              templates:
                  steps:                        
                  - - name: gerrit-checkout
                      template: gerrit-checkout  

                  - - name: compile
                      template: compile
                      arguments:
                        artifacts:
                        - name: source
                          from: "{{steps.gerrit-checkout.outputs.artifacts.source}}"

                  - - name: unittests-componenttests
                      template: unittests-componenttests
                      arguments:
                        artifacts:
                        - name: source
                          from: "{{steps.gerrit-checkout.outputs.artifacts.source}}"

                  - - name: publish-artifacts-arm
                      template: publish-artifacts-arm
                      when: "{{workflow.parameters.gerritevent}} == change-merged"
                      arguments:
                        artifacts:
                        - name: compiled
                          from: "{{steps.compile.outputs.artifacts.compiled}}"

                  - - name: build-and-push-docker-image-to-registry
                      template: build-and-push-docker-image-to-registry
                      when: "{{workflow.parameters.gerritevent}} == change-merged"
                      arguments:
                        artifacts:
                        - name: source
                          from: "{{steps.gerrit-checkout.outputs.artifacts.source}}"               
hideto0710 commented 5 years ago

Maybe -(hyphen) is evaluated as minus. I think we have to escape. https://github.com/Knetic/govaluate/blob/master/README.md#escaping-characters https://github.com/argoproj/argo/pull/1240

magaldima commented 5 years ago

does this when refer to the argo workflow template or the argo-events gateway template? If the prior, please raise this as an issue in the https://github.com/argoproj/argo repo

emichaf commented 5 years ago

Tried Both:

1)
- - name: build-and-push-docker-image-to-registry
                      template: build-and-push-docker-image-to-registry
                      when: "{{workflow.parameters.gerritevent}} == change\\-merged"
                      arguments:
                        artifacts:
                        - name: source
                          from: "{{steps.gerrit-checkout.outputs.artifacts.source}}"  

2)
- - name: build-and-push-docker-image-to-registry
                      template: build-and-push-docker-image-to-registry
                      when: "{{workflow.parameters.gerritevent}} == [change-merged]"
                      arguments:
                        artifacts:
                        - name: source
                          from: "{{steps.gerrit-checkout.outputs.artifacts.source}}"  

It did not work, the workflow execution do not continues to my exit handler, it's hangs!

VaibhavPage commented 5 years ago

This looks like Argo workflow issue. Can you raise it in https://github.com/argoproj/argo/issues?