Skip to content

Commit eb3e4f3

Browse files
committed
feat: add download configuration option to support pre-installed binaries
Add optional `download` config to allow using a pre-installed binary instead of downloading on each run. When `download: false`, uses monorepo-diff-buildkite-plugin from PATH. Benefits: reduced build time, improved security, supports policies against runtime downloads. Defaults to `download: true` for backward compatibility.
1 parent 46011f7 commit eb3e4f3

3 files changed

Lines changed: 45 additions & 2 deletions

File tree

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,30 @@ steps:
281281
trigger: "deploy-foo-service"
282282
```
283283

284+
### `download` (optional)
285+
286+
Default: `true`
287+
288+
By setting `download` to `false`, the plugin will use a pre-installed binary instead of downloading it on each run. The binary `monorepo-diff-buildkite-plugin` must be available in your PATH (typically `/usr/bin`).
289+
290+
This option is useful for:
291+
- Reducing build time by avoiding repeated downloads
292+
- Improving security by using pre-vetted binaries
293+
- Organizations with policies against runtime binary downloads
294+
295+
```yaml
296+
steps:
297+
- label: "Triggering pipelines"
298+
plugins:
299+
- monorepo-diff#v1.5.1:
300+
download: false
301+
diff: "git diff --name-only HEAD~1"
302+
watch:
303+
- path: "foo-service/"
304+
config:
305+
trigger: "deploy-foo-service"
306+
```
307+
284308
### `hooks` (optional)
285309

286310
Currently supports a list of `commands` you wish to execute after the `watched` pipelines have been triggered

hooks/command

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,25 @@ download_binary_and_run() {
106106

107107
# todo: move it to a more secure place
108108
chmod +x ${_executable}
109-
109+
110110
./${_executable}
111111
}
112112

113-
download_binary_and_run "$@" || exit 1
113+
run_preinstalled_binary() {
114+
local _executable="monorepo-diff-buildkite-plugin"
115+
116+
if ! check_cmd "$_executable"; then
117+
err "Binary '$_executable' not found in PATH. Please install it or set download: true"
118+
fi
119+
120+
${_executable} "$@"
121+
}
122+
123+
# Check if download option is disabled (default is true for backward compatibility)
124+
download_enabled="${BUILDKITE_PLUGIN_MONOREPO_DIFF_DOWNLOAD:-true}"
125+
126+
if [[ "$download_enabled" == "false" ]]; then
127+
run_preinstalled_binary "$@" || exit 1
128+
else
129+
download_binary_and_run "$@" || exit 1
130+
fi

plugin.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ configuration:
77
properties:
88
diff:
99
type: string
10+
download:
11+
type: boolean
1012
log_level:
1113
type: string
1214
interpolation:

0 commit comments

Comments
 (0)