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
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.