-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 3ac5165
Showing
4 changed files
with
64 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/bash | ||
hooksDir="${0%/*}" | ||
python "${hooksDir}/../python/setup-hooks.py" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
name: Metahook | ||
description: Run scripts in a repository as buildkite hooks on a per-step basis | ||
author: https://github.com/ca-johnson |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import os | ||
|
||
HOOKDIR = os.path.join(os.path.dirname(__file__), '..', 'hooks') | ||
|
||
hooks = [ | ||
# "environment" # not allowed | ||
"pre-checkout", | ||
"checkout", | ||
"post-checkout", | ||
"pre-command", | ||
"command", | ||
"post-command", | ||
"pre-artifact", | ||
"post-artifact", | ||
"pre-exit", | ||
] | ||
|
||
def cleanup_metahooks(): | ||
"""Remove the temporary hooks""" | ||
hooks = [os.path.join(HOOKDIR, hook) for hook in os.listdir(HOOKDIR)] | ||
for hook in hooks: | ||
if hook == 'environment.sh': | ||
continue # skip the geniuine plugin hook | ||
os.remove(hook) | ||
|
||
def create_metahooks(): | ||
with open(os.path.join(HOOKDIR, 'pre-checkout.sh'), 'w') as outfile: | ||
outfile.write("ls") | ||
|
||
|
||
def main(): | ||
create_metahooks() | ||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# Metahook Buildkite Plugin | ||
|
||
A Buildkite plugin that allows running additional commands as buildkite hooks on a per-step basis. | ||
|
||
# Example | ||
|
||
```yaml | ||
common: &common | ||
plugins: | ||
- ca-johnson/metahook: | ||
post-checkout: scripts/setup.sh | ||
pre-exit: scripts/cleanup.sh | ||
|
||
steps: | ||
- label: "Build" | ||
command: "scripts/build.sh" | ||
<<: *common | ||
|
||
- label: "Test" | ||
command: "scripts/test.sh" | ||
<<: *common | ||
|
||
``` |