Skip to main content

Create and manage task definitions

This guide covers creating a task definition, publishing versions, listing and inspecting task definitions, making one public or private, and deleting a version or a whole task definition, in the platform UI and with the CLI.

Prerequisites​

Creating a task definition or publishing a version needs a verified email, the Admin role in an organization, and an Active billing status on the account. Making a task definition public or private and deleting need a verified email and the Admin role. In an organization, Upload Markdown, Import GitHub, Make Public or Make Private, Delete Definition and Delete Version appear only for Admins and Owners. See Permissions and restrictions.

Write the task definition file​

A task definition is a Markdown file with YAML frontmatter and a non-empty Markdown body:

---
name: My archive task
description: Archives build artifacts.
category: utilities
inputs:
artifact_path:
default: dist
outputs:
archive_path:
description: Path to the generated archive file.
exec:
image: ghcr.io/example/archive-task:1.0.0
args:
- sh
- -c
- |
set -e
tar -czf "$WORKFLOW_STORAGE/archive.tgz" -C "$WORKFLOW_STORAGE" "${{inputs.artifact_path}}"
echo "archive_path=$WORKFLOW_STORAGE/archive.tgz" >> "$WORKFLOW_TASK_OUTPUT"
---

# My archive task

Packages the build output from the provided artifact path, relative to the run's shared workspace.

The command finds the run's shared workspace through the WORKFLOW_STORAGE environment variable, never a hardcoded path, and writes the archive_path output to the file named by WORKFLOW_TASK_OUTPUT. Task definition syntax describes every field, including the rules for name, description, category and outputs, and Runtime storage the storage locations.

If the image is on a private registry, the definition still names only the image. Each workflow that uses it gives the credentials to pull it; see Use a task image from a private registry.

Create a task definition​

With the CLI:

swale task-definition publish \
--name my-task \
--version 1.0.0 \
--file my-task.md

The first publish under a name creates the task definition. Add --public to make it public as it is created.

In the UI:

  1. Open Task Definitions.
  2. Click Upload Markdown.
  3. Select a .md or .markdown file in Markdown file.
  4. Enter a Name and a Version. Check Public to make the task definition public as it is created.
  5. Click Upload.

To take the file from GitHub instead, click Import GitHub, select a connected owner, a repository and a .md or .markdown file, click Next, enter a Name and a Version, and click Import. Connect and manage GitHub integration describes connecting an owner.

The name you give with --name or in Name is the <task-definition> part of the address workflows use, <account>/<task-definition>@<version>. The file's name is only the title, so changing it in a later version leaves the address as it is.

If your account already has a task definition with the name you enter, the CLI and the UI publish the file to it as a new version, and leave its visibility as it is.

Publish a version​

A version cannot be changed once it is published. To change a task definition, publish a new version:

swale task-definition publish \
--name my-task \
--version 1.1.0 \
--file my-task-v2.md

In the UI, upload or import the file with the task definition's existing name and the new version.

The CLI prints Task definition version published: when it adds a version, and Task definition created: when no task definition had the name. If you meant to add a version, the second message means the name was mistyped: delete the new task definition and publish again under the right name.

A version string can be published only once per task definition name; see Versioning.

List and inspect task definitions​

With the CLI:

swale task-definition list

Each task definition is listed with its latest version, or with dashes in place of its version when it has no versions. The Title column is that version's name; the Name column is the <task-definition> part of its address. To see every version of a task definition, most recently published first, each titled with its own name:

swale task-definition list-versions --name my-task

To inspect one version:

swale task-definition get --name my-task --version 1.1.0

In the UI: open Task Definitions. Each task definition shows its title, its address and whether it is Public or Private; click one to open its latest version and the list of its versions. A task definition with no versions shows No versions under its name; clicking it opens the task definition with an empty list of versions.

Make a task definition public or private​

A task definition is private by default: only your account can use it in workflows, whatever versions it has published. Making it public lets every account use it, and shows it on Swale Hub with your account's avatar. Swale Hub is open to everyone on the internet, so search engines and AI systems can read a public task definition there.

In the UI: open the task definition and click Make Public, or Make Private on a public one.

With the CLI:

swale task-definition set-visibility --name my-task --public
swale task-definition set-visibility --name my-task --private

If a version is published to the task definition while you make it public, nothing changes and the command fails. Run it again.

Making a task definition public reserves every version it has, and every version published while it is public, for every account, and making it private again releases none of them; see Versioning. Once it is private, other accounts' runs that use it are refused at start, and a run already under way fails when a task that uses it is about to start; see Task definitions that are no longer available.

Delete a version​

In the UI:

  1. Open the task definition.
  2. Click Delete Version in the version's row.
  3. Click Delete Version to confirm.

With the CLI:

swale task-definition delete-version \
--name my-task \
--version 1.0.0

The deleted version's string stays reserved. To replace a deleted version, publish a new version under a different version string.

Deleting a task definition's last version leaves the task definition in place, with no versions. To remove it, delete the task definition.

Runs that use the deleted version, yours and other accounts', are refused at start, and a run already under way fails when a task that uses it is about to start. See Task definitions that are no longer available.

Delete a task definition​

warning

Deleting a task definition removes all its versions, and cannot be undone. Runs that use any of them, yours and other accounts', are refused at start, and a run already under way fails when a task that uses one is about to start. Its version strings stay reserved, even if you create a task definition with the same name again.

In the UI:

  1. Open the task definition.
  2. Click Delete Definition, then Delete Definition to confirm.

With the CLI:

swale task-definition delete --name my-task

Next steps​