About Waypoint Triggers
Warning
This content is part of the legacy version of Waypoint that is no longer actively maintained. For additional information on the new vision of Waypoint, check out this blog post and the HCP Waypoint documentation.
Trigger URLs are pre-configured Waypoint lifecycle operations for execution inside Continuous Integration (CI) environments. Users can configure operations like deploying the latest build, running a status report on all applications in a project, running a Waypoint Up operation on all applications in a project, and more. Trigger URLs make it easy to run Waypoint operations inside CI without requiring the Waypoint CLI or any other Waypoint setup in your scripts. You will simply need curl to execute a Trigger URL via HTTP.
Trigger URLs can be invoked directly inside an environment with a http request that tells Waypoint to execute the pre-configured action. Trigger URLs configurations are project-scoped, where their actions can operate on every application defined in a project or target a single application inside a project.
Waypoint Trigger CLI
The Waypoint CLI comes with a subcommand that lets you configure and update Trigger URL configurations.
Check out our CLI docs for the waypoint trigger
command, such as
waypoint trigger create.
Pre-configuring a Trigger URL
As an example, you can create a Trigger URL config that deploys the latest artifact
to the production workspace. First, configure the Trigger to use the
right project, application, and workspace. Then, specify which lifecycle operation
you want the trigger to execute when run. You can also include a description
or
tags
for extra information for the user.
Note that creating a trigger does not validate the existence of a Project or
Application. This validation happens at execution time. If you have made a mistake
or typo, you can easily modify an existing trigger with waypoint trigger update
.
Once a trigger has been created, you can make an HTTP request against the given trigger URL to start and queue a job on Waypoint server.
Modifying an existing Trigger URL Configuration
If you wish to see all of your configured triggers inside a Waypoint server,
run the waypoint trigger list
command:
In this example, you'll configure Trigger URLs for the go-gitops-0
project.
Now, let's say you have a status report trigger that only runs on your app
called go
in the default
workspace, but wish for that trigger to refresh the
status in the production
workspace.
First, inspect the Trigger URL configuration to see how it's configured:
For this trigger to run in the production
workspace, update the
trigger's configuration:
For now, you can use this ID to make a request to Waypoint server to execute the trigger.
Running a Trigger URL Configuration via HTTP
/v1/trigger/:trigger-id
The /v1/trigger
endpoint takes a trigger id parameter when initiating a request.
It also accepts 3 request parameters:
token
(string) - For authenticated triggers, providing a token will authorize the request to be executedstream
(string) - If stream is set to anything other than empty string, the server will stream back the job event stream for all queued jobs. Triggers that are not configured for authentication cannot stream back job event streams.variables
(string map)- If set, these variables will be set as input variable overrides for the requested operation (i.e. set a new tag). This must be valid JSON.
Example
In an upcoming version of Waypoint, we will provide an HTTP endpoint for easy access to request running a configured Trigger. When you create a trigger, you'll then see an HTTP url:
Once a trigger has been created, you can request it start via curl
or any other
http request.
If your project includes an input variable that you wish to override on the request,
you can provide a variables
option.
Streaming Job Output over HTTP
When starting a trigger URL request, Waypoint server supports streaming job output to the requester. Additionally, it supports streaming all concurrent jobs that are running from the result of starting a trigger URL. For trigger URLs that are not authenticated, Waypoint server does not allow for job streaming.
Streamed Event Types
When streaming events back from a running job, trigger URLs will return job
stream event message types depending on the kind of output from the job. A job
will be finished if it returns a Complete
or Error
value type.
Complete
Error
TerminalEventLine
TerminalEventNamedValues
TerminalEventStatus
TerminalEventRaw
TerminalEventStep
TerminalEventTable
Example
Streaming output will give you the job event streamed directly to you:
Note that if you cancel watching a job stream, the job will still execute on the server. This does not cancel the queued job.