Task definition reference
The following is a complete reference of fields supported in task definitions. For guides to getting started, see:
What is a task definition?
Task definitions are files that define a task's metadata as code. Task definitions can be written in
yaml
or json
and have the extension .task.yaml
or .task.json
.
Definining tasks as code is advantageous because it allows you to reap the benefits of version control: view the current state of a task and its history, subject tasks to the same code review and deploy mechanisms as the rest of your codebase, or roll back a task to a previous commit.
A task definition file is created when you initialize a task. Once the task is created, the best practice is to make further task updates directly to the task definition file rather than through the UI. This ensures that the task definition file always represents the source of truth.
If you do edit the task through the UI, you can rerun
airplane init --from YOUR_TASK_SLUG path/to/defn.task.yaml
to sync changes back to your task
definition file.
Standard fields
The fields below apply to all task definitions, regardless of the type of task.
A unique identifier that ties this definition file to a task in Airplane. This cannot be changed (a different slug will end up creating a new task).
Slugs must:
- Be less than 50 characters long
- Use only lowercase letters, numbers, and underscores
- Start with a lowercase letter
User-facing name for the task. This can be changed.
User-facing description for the task. This can be changed.
A list of parameters. Each parameter is a user-facing field to input data into the task.
Example:
yamlCopied1parameters:2- slug: name3name: Name4type: shorttext5description: The user's name.6default: Alfred Pennyworth7required: false8options:9- Alfred Pennyworth10- Bruce Wayne11regex: "^[a-zA-Z ]+$"
Unique identifier for the parameter. This is the identifier you'll use to interpolate parameters into arguments, pass them when calling from the CLI, etc.
User-facing name for the parameter.
Possible Values |
shorttextYour commonly used string input |
longtextA string, but with a larger input box for users |
sqlSimilar to Long Text inputs but offer SQL syntax highlighting |
booleanPresented as on/off toggles |
uploadAllows users to upload a file |
Show more |
The type of the parameter. See Parameter types for more information.
User-facing description of the parameter.
Whether the parameter is required.
The default value of the parameter. The type depends on the type of the parameter.
Constrains the value of parameter to a list of options.
The type depends on the type of the parameter.
You can optionally add a label to each option. Labels are shown to the user instead of the value.
To add a label, the option should be an object with fields label
and value
.
Example:
yamlCopied1options:2- Alfred Pennyworth3- Bruce Wayne4- label: BW5value: Bruce Wayne
For more information, see Select options.
Allows you to more dynamically control what values are permitted. For more information, see Regular expressions.
If true, a task must be requested before it is executing. This disables direct execution, including schedules.
Requiring requests will disable schedules. Any existing schedules will be paused on the next attempted execution.
If true, a request can be approved by the requestor.
Limits how long a task can run before it is automatically cancelled.
Maximum of 43200
(12 hours)
For more information, see timeouts.
Restricts this task to run only on agents with matching labels.
Example:
yamlCopied1constraints:2aws-region: us-west-2
For more information, see Run constraints.
Mapping of unique identifiers to schedules that should be deployed with the task.
For more information, see Schedules.
Example:
yamlCopied1schedules:2my_first_schedule:3cron: 0 0 * * *4name: My First Schedule5description: This is my first daily midnight UTC schedule!6paramValues:7my_first_param: my_first_param_value
The unique identifier is used to add, update and remove schedules as changes are made to the task definition file. Adding a new entry will create a new schedule, modifying an entry will update the schedule and removing an entry will pause the schedule.
The unique identifier must adhere to the slug format.
Cron string of the schedule. To see acceptable formats, see Cron syntax.
Name of the schedule.
Description of the schedule.
Map of param slugs and values to pass to the task on each run.
Node.js
Marks the task as a Node.js task.
Example:
yamlCopied1node:2entrypoint: my_task.ts3nodeVersion: "16"
The path to the .ts
or .js
file containing the logic for this task. This
can be absolute or relative to the location of the definition file.
Examples:
yamlCopied1entrypoint: my_folder/my_task.ts
Possible Values |
12 |
14 |
15 |
16 |
The Node.js version the task will be transpiled to.
Environment variables that will be passed into the task.
Environment variables can be entered directly ("from value"), or you can reference Config variables ("from config variable"). Use config variables for secrets and/or values you want to share across multiple tasks.
Example:
yamlCopied1envVars:2# From value3NODE_ENV:4value: production5# From config variable6MY_SECRET:7config: MY_SECRET_CONFIG_VAR
Python
Marks the task as a Python task.
Example:
yamlCopied1python:2entrypoint: my_task.py
The path to the .py
file containing the logic for this task. This
can be absolute or relative to the location of the definition file.
Examples:
yamlCopied1entrypoint: my_folder/my_task.py
Environment variables that will be passed into the task.
Environment variables can be entered directly ("from value"), or you can reference Config variables ("from config variable"). Use config variables for secrets and/or values you want to share across multiple tasks.
Example:
yamlCopied1envVars:2# From value3API_ENDPOINT:4value: api.myco.dev/5# From config variable6MY_SECRET:7config: MY_SECRET_CONFIG_VAR
SQL
Marks the task as a SQL task.
Example:
yamlCopied1sql:2resource: Prod DB3entrypoint: my_task.sql
The name of an SQL resource. If you don't have an existing resource, visit the Resources settings page to add a new resource.
Example:
yamlCopied1resource: Prod DB
The path to the .sql
file containing the SQL query. This
can be absolute or relative to the location of the definition file.
Examples:
yamlCopied1entrypoint: my_folder/my_task.sql
Query arguments that will be passed into the SQL query and referenced as :queryArgName
.
Query arguments can either be hardcoded values or reference parameters as {{params.slug}}
.
Example:
yamlCopied1queryArgs:2name: John3# From parameter4id: "{{params.user_id}}"
These can be used in your SQL script:
sqlCopied1SELECT * FROM users WHERE name = :name AND id = :id;
Possible Values |
auto |
readOnly |
readWrite |
none |
Specify the kind of transaction to use, or none for no transaction. The "auto" value here lets Airplane decide.
Example:
yamlCopied1transactionMode: none
The configs attached to this task. See Config variables for more details on how to use config variables in your task.
Example:
yamlCopied1configs:2- DEFAULT_SQL_PAGE_SIZE
Shell
Marks the task as a Shell task.
Example:
yamlCopied1shell:2entrypoint: my_task.sh
The path to the .sh
file containing the shell script. This
can be absolute or relative to the location of the definition file.
Examples:
yamlCopied1entrypoint: my_folder/my_task.sh
Environment variables that will be passed into the task.
Environment variables can be entered directly ("from value"), or you can reference Config variables ("from config variable"). Use config variables for secrets and/or values you want to share across multiple tasks.
Example:
yamlCopied1envVars:2# From value3ENV:4value: production5# From config variable6MY_SECRET:7config: MY_SECRET_CONFIG_VAR
REST
Marks the task as a REST task.
Examples:
POST
yamlCopied1rest:2resource: Internal API3method: POST4path: "/users/{{params.user_id}}/update"5bodyType: json6body:7name: "{{params.user_name}}"
GET
yamlCopied1rest:2resource: Internal API3method: GET4path: "/users/{{params.user_id}}"5urlParams:6page: 3
The name of a REST API resource. If you don't have an existing resource, visit the Resources settings page to add a new resource.
The path to request. Your REST resource may specify a path prefix as part of its base URL, in which case this path is joined to it. Airplane recommends that this start with a leading slash.
A key value map from param name to value.
Example:
yamlCopied1page: 32name: "{{params.user_name}}"
Possible Values |
json |
raw |
form-data |
x-www-form-urlencoded |
The type of body that this request should send.
The body of the request for a request of method POST
, PUT
or PATCH
.
This field is required when bodytype
is json
or raw
.
Example:
yamlCopied1bodyType: json2body:3name: John4email: "{{params.user_email}}"
The form data of the request for a request of method POST
, PUT
or PATCH
.
This field is required when bodytype
is form-data
or x-www-form-urlencoded
.
Example:
yamlCopied1bodyType: form-data2formData:3name: John4email: "{{params.user_email}}"
The configs attached to this task. See Config variables for more details on how to use config variables in your task.
Example:
yamlCopied1configs:2- API_KEY
Docker
Marks the task as a Docker task.
Example:
yamlCopied1docker:2image: ubuntu:21.043command: "echo {{params.user_name}}"
The name of the image to use.
The Docker command to run.
A Docker entrypoint to override the default image entrypoint. If left unset, Airplane will use the default entrypoint of the image (if any).
Example:
yamlCopied1entrypoint: bash