Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Passing command line arguments to build or any command #118

Open
coulson84 opened this issue Apr 11, 2019 · 5 comments
Open

Passing command line arguments to build or any command #118

coulson84 opened this issue Apr 11, 2019 · 5 comments

Comments

@coulson84
Copy link

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?

@buddhike
Copy link
Member

buddhike commented Apr 11, 2019

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

@buddhike
Copy link
Member

Schema of .mbt.yml is documented here:
https://mbtproject.github.io/mbt/#synopsis

@coulson84
Copy link
Author

coulson84 commented Apr 12, 2019

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?

@buddhike
Copy link
Member

buddhike commented Apr 12, 2019

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 😉

@coulson84
Copy link
Author

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 😞

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants