bitwalker / bitwalker/distillery
[Windows] custom command parameter passing is wonky
- Dominant language
- Elixir
- Stars
- 3k
- Forks
- 398
- PR merge metrics
- No merged PRs in 30d
Description
### Steps to reproduce
1. Create a custom command that accepts parameters - for example:
GetTagHistory.ReleaseTasks.process, with appropriate process function and process.ps1 file.
2. From a command prompt, call the command with parameters, for example:
set "COOKIE=SOME_SECRET_COOKIE" && dl_posbypass_umbrella process --location mylocation --tagfile tagfile.txt
3. Get parameter list in process function that looks like either an empty list (if Release-Ctl eval --mfa "GetTagHistory.ReleaseTasks.process/1" --argv -- "$args" is called), or something strange like
["mylocation", "mylocation", "--tagfile", "tagFile.txt", "--location", "mylocation", "--tagfile", "tagFile.txt", "--location", "mylocation", "--tagfile", "tagFile.txt"]' if Release-Ctl is called with Release-Ctl eval --mfa "GetTagHistory.ReleaseTasks.process/1" --argv -- $args (No quotes around the $args).
### Verbose Logs
Paste the output of the release command you ran with the `--verbose` flag
below in the summary tags (this helps keep the issue easy to navigate):
(Sorry, this doesn't work for me)
```
# Put your logs here!
```
### Description of issue
- What are the expected results?
parameter list received by process function is ["--location","mylocation", "--tagfile", "tagfile.txt"]
- What version of Distillery?
2.0.12
- What OS, Erlang/Elixir versions are you seeing this issue on?
Windows Server 2016/10, Erlang/OTP 21 (ERTS 10.2) , Elixir 1.8
- If possible, also provide your `rel/config.exs`, as it is often
my first troubleshooting question, and you'll save us both time :)
```
# Import all plugins from `rel/plugins`
# They can then be used by adding `plugin MyPlugin` to`
# either an environment, or release definition, where
# `MyPlugin` is the name of the plugin module.
~w(rel plugins *.exs)
|> Path.join()
|> Path.wildcard()
|> Enum.map(&Code.eval_file(&1))
use Mix.Releases.Config,
# This sets the default release built by `mix release`
default_release: :default,
# This sets the default environment used by `mix release`
default_environment: Mix.env()
# For a full list of config options for both releases
# and environments, visit https://hexdocs.pm/distillery/config/distillery.html
# You may define one or more environments in this file,
# an environment's settings will override those of a release
# when building in that environment, this combination of release
# and environment configuration is called a profile
environment :dev do
# If you are running Phoenix, you should make sure that
# server: true is set and the code reloader is disabled,
# even in dev mode.
# It is recommended that you build with MIX_ENV=prod and pass
# the --env flag to Distillery explicitly if you want to use
# dev mode.
set dev_mode: true
set include_erts: false
set cookie: :""
end
environment :prod do
# set include_erts: true
set include_erts: "C:/Program Files/erl10.2"
set include_src: false
set cookie: :"*:E|Z!Qf=.$S!o4c$F_h7NV{th71pn16Fu_M==}wxMd>d.1SVD&|mNN*H7Wr`H}^"
set vm_args: "rel/vm.args"
end
# You may define one or more releases in this file.
# If you have not set a default release, or selected one
# when running `mix release`, the first release in the file
# will be used by default
release :dl_posbypass_umbrella do
set version: "0.1.0"
set applications: [
:runtime_tools,
dl_posbypass_gettaghistory: :permanent,
dl_posbypass_gettaghistory_consoleio: :permanent
]
set commands: [
process: "rel/commands/win/process.ps1"
]
set overlays: [
{:mkdir, "releases/<%= release_version %>/commands/win"},
{:copy, "rel/commands/win/process.ps1", "releases/<%= release_version %>/commands/win/process.ps1"}
]
end
```
Here is the process.ps1 file (without quotes around $args):
```
Write-Host "Running process command..."
Write-host "args: '$($args)'"
Release-Ctl eval --mfa "GetTagHistory.ReleaseTasks.process/1" --argv -- $args
```
Here is the process.ps1 file (with quotes around $args):
```
Write-Host "Running process command..."
Write-host "args: '$($args)'"
Release-Ctl eval --mfa "GetTagHistory.ReleaseTasks.process/1" --argv -- "$args"
```
Here is the GetTagHistory.ReleaseTasks module:
```
defmodule GetTagHistory.ReleaseTasks do
alias GetTagHistory.ConsoleIO.CLI, as: ConsoleIO
@start_apps [:dl_posbypass_gettaghistory, :retryable, :dl_posbypass_gettaghistory_consoleio]
def process(my_args) do
IO.puts "received args: '#{inspect my_args}'"
start_services()
ConsoleIO.main(my_args)
stop_services()
end
defp start_services do
IO.puts("Starting dependencies...")
Enum.each(@start_apps, &Application.ensure_all_started/1)
end
defp stop_services do
IO.puts("Stopping dependencies.")
:init.stop()
end
end
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.