Show display name for command based on parameters

We have this command, which gets called repeatedly with different arguments:

  apply_or_replace_k8s_deployment_and_service:
    parameters:
      deployment_name:
        type: string
      directory:
        type: string
    steps:
      - run:
          name: Apply or replace k8s deployment with kustomize changes
          command: |
            kubectl apply -f Backend/Deploy/Kubernetes/<< parameters.directory >>/base/service.yml
            if ! kubectl get deployment << parameters.deployment_name >> > /dev/null 2>&1; then
               kubectl apply -k Backend/Deploy/Kubernetes/<< parameters.directory >>/$KUSTOMIZE_DIR
            else
               kubectl replace -k Backend/Deploy/Kubernetes/<< parameters.directory >>/$KUSTOMIZE_DIR
            fi
            kubectl rollout status deployment << parameters.deployment_name >>

In CCI’s UI, the same command name shows up for every call (see the screenshot). Is there a way to customize the name that shows up in the UI based on the parameters supplied?

Does something like this work?

    steps:
      - run:
          name: Apply or replace k8s deployment with kustomize changes (deployment: << parameters.deployment_name >> )

I gave it a try but unfortunately it doesn’t work:

Unable to parse YAMLmapping values are not allowed here in 'string', line 230, column 83:     ... th kustomize changes (deployment: << parameters.deployment_name >>)     

Hi @christhegrand,

Thank you for sharing your question on our forum!

As @tartale suggested, you can set a custom name by using name:. The config parser however seems to fail when the value specified is not surrounded in quotes.

Could you try modifying your config as follows?

name: "Apply or replace k8s deployment with kustomize changes (deployment: << parameters.deployment_name >> )"

Best Regards

1 Like

Thanks! That worked.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.