StartTask
client.Environments.Automations.Tasks.Start(ctx, body) (*EnvironmentAutomationTaskStartResponse, error)
POST/gitpod.v1.EnvironmentAutomationService/StartTask
Starts a task by creating a new task execution. This call does not block until the task is started; the task will be started asynchronously.
Use this method to:
- Trigger task execution
- Run one-off tasks
- Start scheduled tasks immediately
Examples
-
Start task:
Creates a new execution of a task.
id: "d2c94c27-3b76-4a42-b88c-95a85e392c68"
StartTask
package main
import (
"context"
"fmt"
"github.com/gitpod-io/gitpod-sdk-go"
"github.com/gitpod-io/gitpod-sdk-go/option"
)
func main() {
client := gitpod.NewClient(
option.WithBearerToken("My Bearer Token"),
)
response, err := client.Environments.Automations.Tasks.Start(context.TODO(), gitpod.EnvironmentAutomationTaskStartParams{
ID: gitpod.F("d2c94c27-3b76-4a42-b88c-95a85e392c68"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.TaskExecution)
}
{
"taskExecution": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"metadata": {
"completedAt": "2019-12-27T18:11:19.117Z",
"createdAt": "2019-12-27T18:11:19.117Z",
"creator": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"environmentId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"startedAt": "2019-12-27T18:11:19.117Z",
"startedBy": "startedBy",
"taskId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
},
"spec": {
"desiredPhase": "TASK_EXECUTION_PHASE_UNSPECIFIED",
"plan": [
{
"steps": [
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"dependsOn": [
"string"
],
"label": "label",
"serviceId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"task": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"spec": {
"command": "command",
"env": [
{
"name": "x",
"value": "value",
"valueFrom": {
"secretRef": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
}
}
],
"prebuildRequiresSuccess": true,
"runsOn": {
"docker": {
"environment": [
"string"
],
"image": "x"
},
"machine": {}
}
}
}
}
]
}
]
},
"status": {
"failureMessage": "failureMessage",
"logUrl": "logUrl",
"phase": "TASK_EXECUTION_PHASE_UNSPECIFIED",
"statusVersion": "statusVersion",
"steps": [
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"failureMessage": "failureMessage",
"output": {
"foo": "string"
},
"phase": "TASK_EXECUTION_PHASE_UNSPECIFIED"
}
]
}
}
}Returns Examples
{
"taskExecution": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"metadata": {
"completedAt": "2019-12-27T18:11:19.117Z",
"createdAt": "2019-12-27T18:11:19.117Z",
"creator": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"principal": "PRINCIPAL_UNSPECIFIED"
},
"environmentId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"startedAt": "2019-12-27T18:11:19.117Z",
"startedBy": "startedBy",
"taskId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
},
"spec": {
"desiredPhase": "TASK_EXECUTION_PHASE_UNSPECIFIED",
"plan": [
{
"steps": [
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"dependsOn": [
"string"
],
"label": "label",
"serviceId": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"task": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"spec": {
"command": "command",
"env": [
{
"name": "x",
"value": "value",
"valueFrom": {
"secretRef": {
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e"
}
}
}
],
"prebuildRequiresSuccess": true,
"runsOn": {
"docker": {
"environment": [
"string"
],
"image": "x"
},
"machine": {}
}
}
}
}
]
}
]
},
"status": {
"failureMessage": "failureMessage",
"logUrl": "logUrl",
"phase": "TASK_EXECUTION_PHASE_UNSPECIFIED",
"statusVersion": "statusVersion",
"steps": [
{
"id": "182bd5e5-6e1a-4fe4-a799-aa6d9a6ab26e",
"failureMessage": "failureMessage",
"output": {
"foo": "string"
},
"phase": "TASK_EXECUTION_PHASE_UNSPECIFIED"
}
]
}
}
}