Skip to content

buildkite/repo-hook-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Buildkite Pre-Command Environment Example

Build status Add to Buildkite

This repository is an example Buildkite pipeline that demonstrates how environment variables can be set through a repository hook.

👉 See this example in action: buildkite/repo-hook-example

See the full Getting Started Guide for step-by-step instructions on how to get this running, or try it yourself:

Add to Buildkite

Screenshot of example pipeline build page

How it works

This pipeline demonstrates how to use the pre-command hook to dynamically set environment variables at runtime for each job.

In this example:

  • .buildkite/hooks/pre-command sets a GIT_SHORT_HASH variable
  • check_environment_var.sh prints that variable
  • The hook runs once per job and is scoped to that job context only

This can be helpful for injecting metadata into your builds without hardcoding values into your pipeline configuration.

Notes

  • Environment vars are scoped to a job context and cleaned up to prevent polluting other job contexts.
  • The environment var exported by pre-command in this example is calculated every time a job in this pipeline is run.
  • If the environment variable was expensive to calculate or non-deterministic, you might want to consider only calculating it during the pipeline upload step and setting the env inside the pipeline.yml

License

See LICENSE (MIT)

About

An example pipeline that sets environment variables using a repository hook.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages