Open
Description
We’re trying to make use of the pre-bootstrap hook functionality (on version 3.33.3
) but have hit an interesting issue which we wanted to raise:
Background:
- We have an agent hooks directory, which we populate with bash scripts to perform our required actions.
Files are named such as:pre-checkout
pre-bootstrap
- We for the most part (aside from some templating/minor tweaks) use the same hooks across different OSs (Windows, Linux in this case)
- This has worked fine for us so far
pre-bootstrap
hooks on Linux works fine
Issue:
- On Windows agents, the
pre-bootstrap
fails with an error like:Error: Error building command: exec: "c:\\users\\buildkite-agent\\AppData\\Local\\buildkite-agent\\hooks\\pre-bootstrap": file does not exist
- We’ve done some digging and it seems that there might be a slightly different code path that gets hit for
pre-bootstrap
. pre-bootstrap
callsRunWithoutPrompt
here- Following the function calls, we get to here where the
PATHEXT
env var is read. - We don’t do anything special to this env var, so it is the Windows Server 2019 default of
.COM;.EXE;.BAT;.CMD;.VBS;.VBE;.JS;.JSE;.WSF;.WSH;.MSC
- We end up in the LookPath function here
- This checks for executables with one of the extensions above.
- This fails in our case as we have a file called
pre-bootstrap
(bash script) which has none of those extensions. - Interestingly, it seems the other hooks take a slightly different approach
- They seem to enter executeHook here
- And then into ScriptWrapper which seems to handle bash hooks fine.
- Following the function calls, we get to here where the
Hopefully I haven't missed anything. The behaviour took us a bit by surprise, we’d like to have our pre-bootstrap hook script be a bash script that can be used across the platforms.