I'm writing a Mix Task that is supposed to be as part of CI and should stop the build process if it fails, which is normally done using exit codes, where 0 code denotes success and non-0 an error. I would want to be able to return an arbitrary exit code to signal different types of failures.
How would I do it in a Mix.Task
? The documentation for the run/1
callback doesn't say anything about it.
Use exit/1
. For example putting exit({:shutdown, 15})
inside your mix task will result in the following:
$ mix compile && mix custom.task
$ echo $?
15