Skip to content

Commit

Permalink
Fix unnecessary capitals and skipping heading levels
Browse files Browse the repository at this point in the history
  • Loading branch information
mbelton-buildkite committed Jun 19, 2023
1 parent 0e6993a commit b66944a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pages/agent/v3/hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@ For example, you could define an agent-wide `checkout` hook that spins up a fres

There are two categories of hooks:

* Agent Lifecycle
* Job Lifecycle
* Agent lifecycle
* Job lifecycle

Agent lifecycle hooks are _executed_ by the Buildkite agent as part of the agent's lifecycle. For example, the `pre-bootstrap` hook is executed before starting a job's bootstrap process, and the `agent-shutdown` hook is executed before the agent process terminates.

Job lifecycle hooks are _sourced_ (see "A note on sourcing" for specifics) by the Buildkite bootstrap in the different job phases. They run in a per-job shell environment, and any exported environment variables are carried to the job's subsequent phases and hooks. For example, the `environment` hook can modify or export new environment variables for the job's subsequent checkout and command phases. Shell options set by individual hooks, such as set `-e -o pipefail`, are not carried over to other phases or hooks.

<details>
<summary> 📝 A note on sourcing </summary>
<p>We use the word "sourcing" on this page, but it's not strictly true. Instead, the agent uses a process called <a href="https://github.com/buildkite/agent/blob/1a5f05029cc363a984188c441f938dd316dedd16/hook/scriptwrapper.go">"the scriptwrapper"</a> to run hooks.</p>
<p>We use the word "sourcing" on this page, but it's not strictly correct. Instead, the agent uses a process called <a href="https://github.com/buildkite/agent/blob/1a5f05029cc363a984188c441f938dd316dedd16/hook/scriptwrapper.go">"the scriptwrapper"</a> to run hooks.</p>

<p>This process notes down the environment variables before a hook run, sources that hook, and compares the environment variables after the hook run to the environment variables before the hook run.</p>

Expand Down Expand Up @@ -87,15 +87,15 @@ In addition to the regular shell script hooks, polyglot hooks enable you to run
Polyglot hooks are run transparently by the agent, and are not distinguished from shell script hooks in the logs or the Buildkite dashboard. The agent will automatically detect the type of hook–whether it's a shell script, an interpreted hook, or a binary–and run it appropriately. All you need to do is place your hook in the correct location and ensure it's executable.

#### Extra environment
### Extra environment variables

When polyglot hooks are called, the following extra environment variables are set:

* `BUILDKITE_HOOK_PHASE` - The lifecycle phase of the hook being run. For example, `environment` or `post-checkout`. See [job lifecycle hooks](#job-lifecycle-hooks) for the full list of phases. This enables the hook to determine the phase it's running in, allowing you to use the same hook for multiple phases.
* `BUILDKITE_HOOK_PATH` - The path to the hook being run. For example, `/path/to/my-hook`.
* `BUILDKITE_HOOK_SCOPE` - The scope of the hook being run. For example, `global`, `local`, or `plugin`.

#### Caveats
### Caveats

Polyglot hook usage comes with the following caveats:

Expand Down

0 comments on commit b66944a

Please sign in to comment.