Migrate Runbooks to Tasks

Learn how Tasks compare to Runbooks
Since Runbooks were launched, a number of new Tasks features have shipped that bring Tasks to parity with Runbooks. Any operation that can be expressed with a Runbook can now be expressed with a Task!

Runbooks vs. Tasks

Tasks are best optimized for developers since they can be used to express orchestration-heavy processes as code. This offers a number of advantages:
  • Control flow is expressed with familiar language constructs such as if statements, for loops, and branches. Runbooks do not support looping and only support limited forms of branching through start conditions.
  • Tasks can be managed as code and automatically deployed.
  • Tasks can make decisions dynamically, such as conditionally requiring approvals.
  • Task code can be reused and executed from within other tasks.
To get started writing Runbook-like operations as Tasks, see the following guide:
While Tasks are optimized for developers who are familiar with programming, Runbooks are optimized for quickly building operations from the Airplane UI. This is the area where Runbooks are an improvement over Tasks. If that is what you are looking for, we recommend you continue to use Runbooks!

How to migrate

The tooling for converting runbooks to tasks is currently in beta and currently only supports generating JavaScript tasks. We'd love to hear any feedback or requests at hello@airplane.dev.
The Airplane CLI provides a way to convert existing runbooks to inline JavaScript Tasks.

Migrating runbook features to task features

You can convert a Runbook to a Task by running:
bash
Copied
1
airplane tasks init --from-runbook MY_RUNBOOK_SLUG
The CLI will create a new Task and attempt to translate each Runbook block to its equivalent Task code:
RunbooksTasks
Replace Task blocks......with the Task execution SDK
Replace Built-in blocks......with Built-in SDK methods
Replace Form blocks......with Prompts
Replace Note blocks......with Text displays
Replace Start conditions......with native if statements
These Runbook global variables can be replaced with the following runtime environment variables:
Runbook GlobalTask Environment Variable
Replace session.id...with process.ENV.AIRPLANE_RUN_ID
Replace session.url...with process.ENV.AIRPLANE_RUN_URL
Replace session.creator.id...with process.ENV.AIRPLANE_RUNNER_ID
Replace session.creator.email...with process.ENV.AIRPLANE_RUNNER_EMAIL
Replace session.creator.name...with process.ENV.AIRPLANE_RUNNER_NAME
Replace runbook.id...with process.ENV.AIRPLANE_TASK_ID
Replace runbook.url...with process.ENV.AIRPLANE_TASK_URL
Replace runbook.name...with process.ENV.AIRPLANE_TASK_NAME
Replace env.id...with process.ENV.AIRPLANE_ENV_ID
Replace env.slug...with process.ENV.AIRPLANE_ENV_SLUG
Replace env.name...with process.ENV.AIRPLANE_ENV_NAME
Replace env.is_default...with process.ENV.AIRPLANE_ENV_IS_DEFAULT

Example

A Runbook that looks up a user in a database and sends a slack message based on the SQL results.

Limitations