anchor.diff:  This page shows you how to write your own Buildkite plugin, and how to validate the `plugin.yml` file which describes it against the plugin schema.
   
   {:toc}
  -
  -## Plugin tutorial
   
   In this tutorial we'll create a Buildkite plugin called "File Counter", which counts the number of files in the build directory once the command has finished, and creates a build annotation with the count.
   
  
positive.code: docker-compose run --rm lint
  ```
  
  ### Publish to the directory
  
  To add your plugin to the [Buildkite Plugin Directory](https://buildkite.com/plugins), publish your repository to a public GitHub repository and add the `buildkite-plugin` repository topic tag. For full instructions, see the [Plugin Directory documentation](/docs/plugins/directory).
  
  ## Plugin schema
  
  Each plugin must have a `plugin.yml` file, which describes the plugin, what it requires, and what configuration options it accepts.
  
  For example:
  
  ```yml
  name: File Counter
  description: Annotates the build with a file count
  author: https://github.com/a-github-user
  requirements: []
  configuration:
    pattern:
      type: string
    additionalProperties: false
  ```
  {: codeblock-file="plugin.yml"}
  
  
  Valid `plugin.yml` properties:
  
  <table>
    <thead>
      <tr>
        <th>Property</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>name</th>
        <td>The name of the plugin, in Title Case.</th>
      </tr>
      <tr>
        <td>description</th>
        <td>A short sentence describing what the plugin does.</th>
      </tr>
      <tr>
        <td>author</th>
        <td>A URL to the plugin author (e.g. website or GitHub profile).</th>
      </tr>
      <tr>
        <td>requirements</th>
        <td>An array of commands that are expected to exist in the agent’s <code>$PATH</code>.</th>
      </tr>
      <tr>
        <td>configuration</th>
        <td>A <a href="https://json-schema.org">JSON Schema</a> describing the valid configuration options available.</th>
      </tr>
    </tbody>
  </table>
  
negative.code: 
  The `configuration` property defines the validation rules for the plugin configuration using the [JSON Schema](https://json-schema.org) format. We’ve specified that the plugin has a single `pattern` property, of type `string`.
  
  Configuration properties are available to the hook script as environment variables with the naming pattern `BUILDKITE_PLUGIN_<PLUGIN_NAME>_<CONFIGURATION_PROPERTY>` where `<PLUGIN_NAME>` is the GitHub repository slug, not the name definited in `plugin.yml`. In this case, the configured value of `pattern` will be available as `BUILDKITE_PLUGIN_FILE_COUNTER_PATTERN`.
  
  <div class="Docs__troubleshooting-note">
    <h3>Plugin properties and git</h3>
    <p>
      Note that if you <a href="docs/plugins/using#plugin-sources">reference a plugin</a> using a full URL and <code>.git</code> extension, you need to use a slightly different syntax to get access to the configuration properties. For example, to get the value of <code>pattern</code> in <code>https://github.com/my-org/my-plugin.git#v1.0.0</code> use  <code>BUILDKITE_PLUGIN_MY_PLUGIN_GIT_PATTERN</code>.
    </p>
  </div>
  
  ### Valid plugin.yml properties
  
  <table>
    <thead>
      <tr>
        <th>Property</th>
        <th>Description</th>
      </tr>
    </thead>
    <tbody>
      <tr>
        <td>name</th>
        <td>The name of the plugin, in Title Case.</th>
      </tr>
      <tr>
        <td>description</th>
        <td>A short sentence describing what the plugin does.</th>
      </tr>
      <tr>
        <td>author</th>
        <td>A URL to the plugin author (e.g. website or GitHub profile).</th>
      </tr>
      <tr>
        <td>requirements</th>
        <td>An array of commands that are expected to exist in the agent’s <code>$PATH</code>.</th>
      </tr>
      <tr>
        <td>configuration</th>
        <td>A <a href="https://json-schema.org">JSON Schema</a> describing the valid configuration options available.</th>
      </tr>
    </tbody>
  </table>
  
  ## Validate the plugin.yml
  
  The [Buildkite Plugin Linter](https://github.com/buildkite-plugins/buildkite-plugin-linter) helps ensure your plugin is up-to-date, and has all the required files to be listed in the plugin directory.
  
  