LogoLogo
HomeBlogGet a Demo
  • Introduction
  • Install Lunar
  • Learn the basics
  • 📖Docs
    • Key concepts
    • Component JSON
    • Catalog JSON
    • Lunar CLI Reference
  • 📝Configuration
    • lunar-config.yml
      • catalogers
      • catalogers/hooks
      • domains
      • components
      • collectors
      • collectors/hooks
      • policies
    • lunar.yml
  • 🛠️Plugin SDKs
    • Plugins configuration
      • lunar-cataloger.yml
      • lunar-collector.yml
      • lunar-policy.yml
    • Bash SDK
      • Cataloger
      • Collector
    • Python SDK
      • Collector
      • Policy
        • Check
        • Path
        • ComponentData
        • NoDataError
        • Utility Functions
  • ⚙️SQL API
    • Overview
    • Views
      • domains
      • components
      • component_deltas
      • initiatives
      • policies
      • checks
      • prs
      • catalog
Powered by GitBook

©️ Earthly Technologies

On this page
  • Collector Hooks
  • Collector Hook
  1. Configuration
  2. lunar-config.yml

collectors/hooks

Collector Hooks

  • lunar-config.yml -> collectors.<collector-index>.hooks

  • lunar-collector.yml -> collectors.<collector-index>.hooks

  • Type: array

  • Form:

    hooks:
      - <hook-configuration>
      - <hook-configuration>
      - ...

Hooks defines when a collector should run.

Example hooks definition:

hooks:
  - type: ci-before-command
    pattern: ^go build.*
  - type: code
  - type: cron
    schedule: "0 2 * * *"

Collector Hook

  • lunar-config.yml -> collectors.<collector-index>.hooks.<hook-index>

  • lunar-collector.yml -> collectors.<collector-index>.hooks.<hook-index>

  • Type: object

  • Form:

    type: <hook-type>
    <options>

A collector hook defines a trigger point for when a collector should run. Collectors can be triggered by various events such as code changes, CI pipeline events, or cron schedules.

Different hooks will cause the collector to execute in different contexts. For example, ci-* hooks will execute the collector in the context of the CI pipeline, while code and cron hooks will execute on a Lunar runner.

A hook has different configuration options depending on the type of event it is triggered by.

Hook types

ci-before-job

  • Form:

    type: ci-before-job
    pattern: <regex-pattern>

The ci-before-job type triggers the collector before a CI job is run. The collector will run if the job name matches the specified regex pattern.

If no pattern is specified, the collector will run before every job.

ci-after-job

  • Form:

    type: ci-after-job
    pattern: <regex-pattern>

The ci-after-job type triggers the collector after a CI job is run. The collector will run if the job name matches the specified regex pattern.

If no pattern is specified, the collector will run after every job.

ci-before-step

  • Form:

    type: ci-before-step
    pattern: <regex-pattern>

The ci-before-step type triggers the collector before a CI step is run. The collector will run if the step name matches the specified regex pattern.

If no pattern is specified, the collector will run before every step.

ci-after-step

  • Form:

    type: ci-after-step
    pattern: <regex-pattern>

The ci-after-step type triggers the collector after a CI step is run. The collector will run if the step name matches the specified regex pattern.

If no pattern is specified, the collector will run after every step.

ci-before-command

  • Form:

    type: ci-before-command
    pattern: <regex-pattern>

The ci-before-command type triggers the collector before a command is run in the CI pipeline. The collector will run if the command line matches the specified regex pattern.

The command can be any process within the CI pipeline even if it is wrapped in scripts or called from other commands.

ci-after-command

  • Form:

    type: ci-after-command
    pattern: <regex-pattern>

The ci-after-command type triggers the collector after a command is run in the CI pipeline. The collector will run if the command line matches the specified regex pattern.

The command can be any process within the CI pipeline even if it is wrapped in scripts or called from other commands.

code

  • Form:

    type: code

The code type triggers the collector when the code of the component changes (i.e. there are new commits).

cron

  • Form:

    type: cron
    clone-code: <boolean>
    schedule: <cron-schedule>

The cron type triggers the collector on a cron schedule. The collector will run according to the specified cron schedule.

If the clone-code option is set to true, the collector will execute in the context of the code repository. This means that the collector will have access to a git clone of the code repository and to interact with.

PreviouscollectorsNextpolicies

Last updated 15 days ago

📝