Configure tasks

This document describes how to configure tasks in Cloud Deploy. A task is a unit of work that can be used as a deploy hook, for deployment verification, for deploy analysis, or for a custom render or custom deploy in a custom target type.

You can configure a task on the delivery pipeline (as part of the strategy) or the custom target type render or deploy.

With tasks, you can use system parameters by templating them into your task configuration.

Define a task

You can define a task in your delivery pipeline configuration or as part of a custom target type definition. The following YAML shows the task stanza used in either case:

  task:
    type: container
    image: IMAGE
    command: [COMMANDS_TO_RUN]
    args: [LIST_OF_ARGS]
    env:
    - KEY1:VAL1
    - KEY2:VAL2
    ...

For the task configuration:

  • type

    Specifies the kind of task being configured. Only container is supported.

  • image

    Is the path to the container image.

  • command

    Is the command or commands to run on the container.

  • args

    Is a collection of arguments to the command.

  • env

    Is a collection of environment variables to be provided to the running container.

System Parameters as task environment variables

Cloud Deploy offers system-generated parameters that you can use as environment variables in your tasks, using the env field in the container task. The templated parameters can be present in the key or value fields of an env map entry.

Here are a couple of example use cases:

  • Passing in the Cloud Run service name, service URL, and revision name as environment variables.

    task:
      type: container
      image: my-image
      command: ["/bin/bash"]
      env:
      - RUN_SERVICE_NAME : "${{ render.metadata.cloud_run.service.name }}"
      - RUN_SERVICE_URL: