Creating Automations
To create a dynamic automation, use the Gitpod CLI to generate or obtain the automation configuration and pipe it directly into thegitpod automations update -
command. Notice the -
at the end which signals that we want to read the Automations from stdin.
When generating tasks and services, keep in mind that their IDs can only contain alphanumeric characters, underscores, and hyphens, and must be between 1 and 128 characters long.Basic example:
Example uses
-
Exposing Package Scripts: Create tasks from scripts in a
package.json
file:This example usesgsub
to ensure all task IDs comply with the required format. -
Dynamic Service Creation: Create services for components in a specific directory:
Suppose you have a
components
directory which contains a set of Go components. The following command creates services for each of those components. -
Remote Automation Configuration: Download and apply Automations from a remote source:
Only ever download Automations from sources you trust; better yet, verify the integrity of the Automations file before applying it.
Make sure that the remote configuration file uses compliant task and service IDs.
Interacting with Dynamic Automations from Outside an Environment
One of Gitpod’s most powerful features is the ability to interact with and control Automations from outside the environment itself. This capability, combined with Gitpod’s environment management features, transforms Gitpod into a flexible automation and execution platform. You can orchestrate complex workflows and tasks without needing to be actively connected to an environment. When interacting with Automations from outside an environment, you can perform the same operations as from within an environment:- Execute Tasks: Start, monitor, and manage automation tasks in remote environments.
- Control Services: Start, stop, and manage long-running automation services.
- Access Logs: Retrieve and monitor logs from tasks and services running in the environment.
- Update Automations: Modify automation configurations for environments on the fly.
Example Workflow: Create, Execute Automation, and Clean Up
Here’s a concrete example of how you might use these capabilities along with Gitpod’s environment management to create an environment, run an automation task, and then clean up:- Create a new environment based on a Git repository.
- Start a specific automation task (in this case, ‘build-and-test’) in that environment.
- Stream the logs of the automation task to monitor its progress.
- Check the final status of the automation task.
- Based on the task’s outcome, either clean up the environment or leave it running for further investigation.
Benefits of External Automation Control
- CI/CD Integration: Easily integrate Gitpod Automations into your existing CI/CD pipelines.
- Batch Processing: Set up and run multiple automation tasks across different environments in parallel for large-scale operations.
- Automated Testing: Create ephemeral environments for running automated test suites without manual intervention.
- Resource Optimization: Run Automations in environments only when needed and automatically clean them up after use.