Closed nathanpurcell closed 6 years ago
Turns out you can just return a string from the closure without using the Composer object (I think I fried my brain staring at this yesterday):
Where you usually have (stategies.php
):
'composer' => [
'install' => function (Composer $composer, $task) {
return $composer->install([], [
'--no-interaction' => null,
'--no-dev' => null,
'--prefer-dist' => null
]);
}
]
You can just return the required install command:
'composer' => [
'install' => function (Composer $composer, $task) {
return 'COMPOSER_AUTH=\'{"bitbucket-oauth": {"bitbucket.org": {"consumer-key": "KEY","consumer-secret": "SECRET"}}}\' composer install --no-interaction --no-dev --prefer-dist';
}
]
I'm looking for a bit of help on how to pass an environment variable (namely COMPOSER_AUTH) to the composer install strategy.
The challenge:
I have a private project hosted on BitBucket - that project requires a private package that is also stored on BitBucket. Locally, I have an
auth.json
file sitting next to mycomposer.json
with the correct repo config set so when I runcomposer install
Composer reads the oauth key and secret and everything works as expected.The problem:
The problem is that I do not want to commit the
auth.json
file to my repository, so now when I run composer install (or rather, Rocketeer does) it can't find the required key and secret.After digging through lots of historic issues in BitBucket, Composer and Rocketeer I've discovered a solution that works when executing by hand:
How can I add the env var to the strategy in the Rocketeer config? It looks as though the $composer object accepts an array of dependencies as the first argument and an array of options/flags as the second. I have tried passing --COMPOSER_AUTH in the second argument but that isn't working.
There may be another way to achieve this but my CLI experience is lacking.
Any help appreciated!