UpsertAutomationsFile
client.Environments.Automations.Upsert(ctx, body) (*EnvironmentAutomationUpsertResponse, error)
POST/gitpod.v1.EnvironmentAutomationService/UpsertAutomationsFile
Upserts the automations file for the given environment.
Use this method to:
- Configure environment automations
- Update automation settings
- Manage automation files
Examples
-
Update automations file:
Updates or creates the automations configuration.
environmentId: "07e03a28-65a5-4d98-b532-8ea67b188048" automationsFile: services: web-server: name: "Web Server" description: "Development web server" commands: start: "npm run dev" ready: "curl -s http://localhost:3000" triggeredBy: - postDevcontainerStart tasks: build: name: "Build Project" description: "Builds the project artifacts" command: "npm run build" triggeredBy: - postEnvironmentStart
UpsertAutomationsFile
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.Upsert(context.TODO(), gitpod.EnvironmentAutomationUpsertParams{
AutomationsFile: gitpod.F(gitpod.AutomationsFileParam{
Services: gitpod.F(map[string]gitpod.AutomationsFileServiceParam{
"web-server": gitpod.AutomationsFileServiceParam{
Commands: gitpod.F(gitpod.AutomationsFileServicesCommandsParam{
Ready: gitpod.F("curl -s http://localhost:3000"),
Start: gitpod.F("npm run dev"),
}),
Description: gitpod.F("Development web server"),
Name: gitpod.F("Web Server"),
TriggeredBy: gitpod.F([]gitpod.AutomationsFileServicesTriggeredBy{gitpod.AutomationsFileServicesTriggeredByPostDevcontainerStart}),
},
}),
Tasks: gitpod.F(map[string]gitpod.AutomationsFileTaskParam{
"build": gitpod.AutomationsFileTaskParam{
Command: gitpod.F("npm run build"),
Description: gitpod.F("Builds the project artifacts"),
Name: gitpod.F("Build Project"),
TriggeredBy: gitpod.F([]gitpod.AutomationsFileTasksTriggeredBy{gitpod.AutomationsFileTasksTriggeredByPostEnvironmentStart}),
},
}),
}),
EnvironmentID: gitpod.F("07e03a28-65a5-4d98-b532-8ea67b188048"),
})
if err != nil {
panic(err.Error())
}
fmt.Printf("%+v\n", response.UpdatedServiceIDs)
}
{
"updatedServiceIds": [
"string"
],
"updatedTaskIds": [
"string"
]
}Returns Examples
{
"updatedServiceIds": [
"string"
],
"updatedTaskIds": [
"string"
]
}