Pause, abort, restart, and report results for builds.
harbormaster.sendmessage
API Method: harbormaster.sendmessage
- Summary
- Modify running builds, and report build results.
- Returns
- void
- Errors
- ERR-CONDUIT-CORE: See error message for details.
- OAuth Scope
- OAuth clients may never call this method.
Method Description
Sending Messages
Harbormaster build objects work somewhat differently from objects in many other applications. Most application objects can be edited directly using synchronous APIs (like maniphest.edit, differential.revision.edit, and so on).
However, builds require long-running background processing and Habormaster objects have a more complex lifecycle than most other application objects and may spend significant periods of time locked by daemon processes during build execition. A synchronous edit might need to wait an arbitrarily long amount of time for this lock to become available so the edit could be applied.
Additionally, some edits may also require an arbitrarily long amount of time to complete. For example, aborting a build may execute cleanup steps which take minutes (or even hours) to complete.
Since a synchronous API could not guarantee it could return results to the caller in a reasonable amount of time, the edit API for Harbormaster build objects is asynchronous: to update a Harbormaster build or build target, use this API (harbormaster.sendmessage) to send it a message describing an edit you would like to effect or additional information you want to provide. The message will be processed by the daemons once the build or target reaches a suitable state to receive messages.
Select an object to send a message to using the receiver parameter. This API method can send messages to multiple types of objects:
Object Type | PHID Example | Description |
---|---|---|
Harbormaster Buildable | PHID-HMBB-... | Buildables may receive control commands like "abort" and "restart". Sending a control command to a Buildable is the same as sending it to each Build for the Buildable. |
Harbormaster Build | PHID-HMBD-... | Builds may receive control commands like "pause", "resume", "abort", and "restart". |
Harbormaster Build Target | PHID-HMBT-... | Build Targets may receive build status and result messages, like "pass" or "fail". |
See below for specifics on sending messages to different object types.
Updating Builds
You can use this method (harbormaster.sendmessage) to send control commands to Buildables and Builds.
Specify the Build or Buildable to receive the control command by providing its PHID in the receiver parameter.
Sending a control command to a Buildable has the same effect as sending it to each Build for the Buildable. For example, sending a "Pause" message to a Buildable will pause all builds for the Buildable (or at least attempt to).
When sending control commands, the unit and lint parameters of this API method must be omitted. You can not report lint or unit results directly to a Build or Buildable, and can not report them alongside a control command.
More broadly, you can not report build results directly to a Build or Buildable. Instead, report results to a Build Target.
See below for a list of control commands.
Control Commands
You can use this method to send control commands to Buildables and Builds.
This table summarizes which object types may receive control commands:
Object Type | PHID Example | Description | |
---|---|---|---|
Harbormaster Buildable | PHID-HMBB-... | Buildables may receive control commands. | |
Harbormaster Build | PHID-HMBD-... | Builds may receive control commands. | |
Harbormaster Build Target | PHID-HMBT-... | You may NOT send control commands to build targets. |
You can send these commands:
Message Type | Description |
---|---|
abort | Abort the build, discarding progress. |
pause | Pause the build. |
restart | Restart the build, discarding all progress. |
resume | Resume work on a previously paused build. |
To send a command message, specify the PHID of the object you would like to receive the message using the receiver parameter, and specify the message type using the type parameter.
Updating Build Targets
If you run external builds, you can use this method to publish build results back into Harbormaster after the external system finishes work (or as it makes progress).
To report build status or results, you must send a message to the appropriate Build Target. This table summarizes which object types may receive build status and result messages:
Object Type | PHID Example | Description | |
---|---|---|---|
Harbormaster Buildable | PHID-HMBB-... | Buildables may NOT receive status or result messages. | |
Harbormaster Build | PHID-HMBD-... | Builds may NOT receive status or result messages. | |
Harbormaster Build Target | PHID-HMBT-... | Report build status and results to Build Targets. |
The simplest way to use this method to report build results is to call it once after the build finishes with a pass or fail message. This will record the build result, and continue the next step in the build if the build was waiting for a result.
When you send a status message about a build target, you can optionally include detailed lint or unit results alongside the message. See below for details.
If you want to report intermediate results but a build hasn't completed yet, you can use the work message. This message doesn't have any direct effects, but allows you to send additional data to update the progress of the build target. The target will continue waiting for a completion message, but the UI will update to show the progress which has been made.
When sending a message to a build target to report the status or results of a build, your message must include a type which describes the overall state of the build. For example, use pass to tell Harbormaster that a build target completed successfully.
Supported message types are:
Type | Description |
---|---|
pass | Report that the target is complete, and the target has passed. |
fail | Report that the target is complete, and the target has failed. |
work | Report that work on the target is ongoing. This message can be used to report partial results during a build. |
Reporting Unit Results
You can report test results when updating the state of a build target. The simplest way to do this is to report all the results alongside a pass or fail message, but you can also send a work message to report intermediate results.
To provide unit test results, pass a list of results in the unit parameter. Each result should be a dictionary with these keys:
Key | Type | Description |
---|---|---|
name | string | Short test name, like "ExampleTest". |
result | string | Result of the test. |
namespace | optional string | Optional namespace for this test. This is organizational and is often a class or module name, like "ExampleTestCase". |
engine | optional string | Test engine running the test, like "JavascriptTestEngine". This primarily prevents collisions between tests with the same name in different test suites (for example, a Javascript test and a Python test). |
duration | optional float or int | Runtime duration of the test, in seconds. |
path | optional string | Path to the file where the test is declared, relative to the project root. |
coverage | optional map<string, wild> | Coverage information for this test. |
details | optional string | Additional human-readable information about the failure. |
format | optional string | Format for the text provided in "details". Valid values are "text" (default) or "remarkup". This controls how test details are rendered when shown to users. |
The result parameter recognizes these test results:
Key | Name | Description |
---|---|---|
pass | Pass | The test passed. |
fail | Fail | The test failed. |
skip | Skip | The test was not executed. |
broken | Broken | The test failed in an abnormal or severe way. For example, the harness crashed instead of reporting a failure. |
unsound | Unsound | The test failed, but this change is probably not what broke it. For example, it might have already been failing. |
This is a simple, valid value for the unit parameter. It reports one passing test and one failing test:
[ { "name": "PassingTest", "result": "pass" }, { "name": "FailingTest", "result": "fail" } ]
Reporting Lint Results
Like unit test results, you can report lint results when updating the state of a build target. The lint parameter should contain results as a list of dictionaries with these keys:
Key | Type | Description |
---|---|---|
name | string | Short message name, like "Syntax Error". |
code | string | Lint message code identifying the type of message, like "ERR123". |
severity | string | Severity of the message. |
path | string | Path to the file containing the lint message, from the project root. |
line | optional int | Line number in the file where the text which triggered the message first appears. The first line of the file is line 1, not line 0. |
char | optional int | Byte position on the line where the text which triggered the message starts. The first byte on the line is byte 1, not byte 0. This position is byte-based (not character-based) because not all lintable files have a valid character encoding. |
description | optional string | Long explanation of the lint message. |
The severity parameter recognizes these severity levels:
Key | Name |
---|---|
advice | Advice |
autofix | Auto-Fix |
warning | Warning |
error | Error |
disabled | Disabled |
This is a simple, valid value for the lint parameter. It reports one error and one warning:
[ { "name": "Syntax Error", "code": "EXAMPLE1", "severity": "error", "path": "path/to/example.c", "line": 17, "char": 3 }, { "name": "Not A Haiku", "code": "EXAMPLE2", "severity": "error", "path": "path/to/source.cpp", "line": 23, "char": 1, "description": "This function definition is not a haiku." } ]
Call Method
Examples
- Use the Conduit API Tokens panel in Settings to generate or manage API tokens.
- If you submit parameters, these examples will update to show exactly how to encode the parameters you submit.
-d api.token=api-token \
-d param=value \
...