You can use an validation extension to enforce custom checks, verification and linting rules to .drone.yml configuration files.
Configuration
You can register a validation extension by providing the following configuration parameters to the Drone server:
-
DRONE_VALIDATE_PLUGIN_ENDPOINT
- Provides the endpoint used to make http requests to an extension.
-
DRONE_VALIDATE_PLUGIN_SECRET
- Provides the token used to authenticate http requests to the extension. This token is shared between the server and extension.
How it Works
The server makes an HTTP post to the validation extension before the yaml file is processed and before any pipelines are scheduled. The validation extension is expected to accept or reject the yaml file.
Request
The validation extension receives an HTTP request to verify the yaml. The request body includes the Repository and Build details in JSON format, as well as the raw Yaml configuration file.
Request Body definition:
|
|
|
|
|
|
|
|
Response
The validation extension should respond with one of the following:
200
response code indicating the yaml passed validation400
response code indicating the yaml failed validation, with a JSON encoded error messaging indicating why validation failed.498
response code indicating the yaml failed validation and should be skipped.499
response code indicating the yaml failed validation and should be blocked, pending manual approval.
{
"message": "cannot use image from external registry"
}
Authorization
The http request is signed per the http signatures draft specification use the shared secret. The receiver should use the signature to verify the authenticity and integrity of the webhook.
Starter Project
If you are interested in creating an validation extension we recommend using our starter project as a base to jumpstart development.