webhook icon indicating copy to clipboard operation
webhook copied to clipboard

How to pass temporary file name as command line argument?

Open robertmircea opened this issue 6 years ago • 1 comments

I am trying to perform the following scenario:

  • read entire payload
  • save the payload to disk in a temporary file
  • execute a command with temporary file name as argument

How can I pass the temporary file name as command line argument for the command to execute? I've reached this stage, but it doesn't work. Ideally I would not like to use a shell script, but call jq directly.

---
- id: "echo"
  execute-command: "jq"
  command-working-directory: ""
  pass-arguments-to-command:
    - source: string
      name: "."
  pass-file-to-command:
    - source: entire-payload
      name: payload

and the output:

[webhook] 2019/11/30 17:27:55 200 | 129.59µs | localhost:9000 | POST /hooks/echo
[webhook] 2019/11/30 17:27:55 [466d25] writing env HOOK_PAYLOAD file /var/folders/c6/45sj77fj3d74s5qn5sxk44mr0000gn/T/HOOK_PAYLOAD060293216
[webhook] 2019/11/30 17:27:55 [466d25] executing jq (/usr/local/bin/jq) with arguments ["jq" "."] and environment [HOOK_PAYLOAD=/var/folders/c6/45sj77fj3d74s5qn5sxk44mr0000gn/T/HOOK_PAYLOAD060293216] using  as cwd
[webhook] 2019/11/30 17:27:55 [466d25] command output:
[webhook] 2019/11/30 17:27:55 [466d25] removing file /var/folders/c6/45sj77fj3d74s5qn5sxk44mr0000gn/T/HOOK_PAYLOAD060293216
[webhook] 2019/11/30 17:27:55 [466d25] finished handling echo

robertmircea avatar Nov 30 '19 15:11 robertmircea

There's currently no way to do what you want without a shell script. pass-file-to-command only provides the filename as an environment variable, and webhook doesn't provide a means of passing that value to pass-arguments-to-command.

moorereason avatar Nov 30 '19 16:11 moorereason