Question about Windows permissions for buildkite agent

Hi everyone!

I’m having some issues on executing a plugin hook on a Windows agent (v3).
Currently my agent is being run by nssm-2.4 as recommended by the installation documentation with my Windows user.

When I try to run the following steps I get a generic error:

  - label: "Testing plugin"
      - example command
      - natasg/test#v1.0.0:
          message: 'Hi there!'

This downloads the plugin from Github as expected and when it’s going to execute it I get the following logs with the error on the last line:

Running plugin test post-command hook
> C:\buildkite-agent\plugins\github-com-natasg-test-buildkite-plugin-v1-0-0\hooks\post-command
he file cannot be accessed by the system.

The file itself is in there and permission wise everything seems to be fine.
Is this related to a permission issue (seems fine for me), because I’m using Powershell as the SHELL and the hook is written in Bash or am I missing something else?

Thank you.

Hi @flavioarieta welcome to the forum :wave:

That looks like its an issue between powershell and bash as you mentioned. Are you able to run an agent manually on your windows host using bash and see if it works that way?

Hi @jarryd! Thank you for your reply.

Executing the agent through bash and changing the SHELL to “C:\Windows\System32/bash.exe” gave me some weird results, I replaced the ‘example command’ with a ‘echo “-----”’ just to have a bash command in place.

> echo "-----"
/bin/bash: echo "-----": No such file or directory
🚨 Error: The command exited with status 127
Running plugin test post-command hook
> C:\buildkite-agent\plugins\github-com-natasg-test-buildkite-plugin-v1-0-0\hooks\post-command
/bin/bash: C:/Users/AVATAR~1/AppData/Local/Temp/buildkite-agent-bootstrap-hook-runner-1514048708: No such file or directory
user command error: exit status 127

Now the command itself cannot be executed too. Just to be sure which value should I use for the SHELL configuration inside buildkite-agent.cfg?

Thank you.

Hey @flavioarieta!

I think the issue here is actually going to be the hooks in general on Windows; Windows doesn’t offer a means to run shell scripts natively, so anything you’re trying to run that ends in .sh or starts with


will face issues in running.

Ref: Installing Buildkite Agent on Windows v3 | Buildkite Documentation

You’ll likely want to run your scirpts as .ps1 files, but that will limit their reach in a sense that they won’t be runnable on Linux.

Hi @benmc!

Got it. I was just puzzled on how it would have ran the bash scripts properly.
Thank you.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.