CircleCI Ideas

Add when on_fail support to commands

I have a custom command which looks something like:

commands:
diagnose_kubernetes_failure:
steps:
- run: minikube status
- run: kubectl get namespace
- run: kubectl get pods -n "${NAMESPACE}"
- run: kubectl get events -n "${NAMESPACE}"
- run: kubectl get pods -n "${NAMESPACE}" --field-selector=status.phase!=Running -o name | xargs -I {} kubectl logs -n "${NAMESPACE}" "{}"

I would really like to be able to do this:

jobs:
test:
- run: do_something
- diagnose_kubernetes_failure:
when: on_fail

Clearly this doesn't work and instead I have to add the when: on_fail to every step in the command.

 

This has also been asked on https://discuss.circleci.com/t/conditional-commands/30682.

  • Avatar32.5fb70cce7410889e661286fd7f1897de Guest
  • Oct 9 2019
  • New
  • Attach files