mbt
mbt copied to clipboard
Passing command line arguments to `build` or any command
Is it possible to pass command line arguments when calling mbt build
or mbt run-in
I am looking to use mbt for but currently we would call, for example,
npm run dev:eap -- --DEV_API <custom host domain>
or to pass arguments in during a build that configure how the build executes. Is there any way to do this with mbt I couldn't see anything in the documentation that indicated it was possible?
Custom arguments are specified in .mbt.yml
. In this instance (assuming this is your build command in linux), you could do something like:
build:
linux:
cmd: npm
args: ['run', 'dev:eap', '--', '--DEV_API', <custom host domain>]
hth
Schema of .mbt.yml
is documented here:
https://mbtproject.github.io/mbt/#synopsis
I understand that but the <custom host domain> will change according to the stage we are building - for development it is one thing, testing it is different and so on. Is there a way to have the <custom host domain> value, in the args array, change according to values passed in from the command line?
Sorry I misunderstood your question 😊.
Currently this is supported via environment variables. To achieve this, you would need a script like this:
#!/bin/sh
set -e
npm run dev:eap -- --DEV_API $DEV_API
Then you configure that as your command in .mbt.yml
and at the point you invoke build, you do so with the correct environment values.
DEV_API="https://dev-api/" mbt build
As a side note, it would be really nice to have a feature to expand arguments to a command with environment variables so that you would not have to write the wrapper script 😉
Yeah - this is the approach I thought I would have to take (but hoped I could avoid). Thanks for the response. Would like to offer my help developing this as a feature but don't have much free time at the moment 😞