3

I am trying to use Drush to execute some commands as part of my CI/CD workflow. The problem is that due to it's flexibility I want to avoid using site aliases which would basically mean writing temporary files during the build process (I really want to avoid that).

However, I've been trying to use --remote-host, --remote-user and --root in-line (e.g. 'drush --remote-host=example.com --remote-user=exampleuser --root=/var/www/example.com') without success. I did some debugging with XDebug and it seems that even though Drush initially picks up the provided command-line options it later purges them again/overrides them at some point. Is that a Drush Bug or am I doing something wrong / missing something?

Will do some further debugging now but maybe someone knows the answer ;).

  • Maybe it's not important for the question, but I don't understand the first paragraph. Why is it you don't want to use aliases? Debugging Drush is, in my experience, quite a complex problem. Since Greg anderson is quite active on the site, I believe the best bet would be to (ab)use your community karma (I assuem I know who's behind the username) and try to nudge him to take a look at this question. :) – Letharion Jan 11 '14 at 19:14
  • Hey Claes! Well, I want to avoid aliases because of how our CI/CD setup works. The delivery part is fully automated and the only way to use site-aliases without crippling it's flexibility would be to dynamically write a temporary site-alias file for the time the build runs and include it with the --alias-path option. Why? Because the Ant build script is used across many projects in our CI server and configured with variables from each project configuration (including the host to which to deploy). – fubhy Jan 11 '14 at 19:22
  • "Debugging Drush is, in my experience, quite a complex problem." Luckily I frequently write a lot of custom Drush commands so I am well prepared for that ;) – fubhy Jan 11 '14 at 19:27
  • Did you try using @none as the site alias? – benjifisher Jan 11 '14 at 19:35
  • Yep! Tried that. No luck :(. (But I thought I was soooo clever when I tried that... He he) – fubhy Jan 11 '14 at 19:41
4

Drush internally converts site aliases into command line options before doing a remote dispatch, so I would expect that you should be able to make --remote-host work without creating an alias.

Here is something that I tried.

$ drush @live sql-conf -v
Calling proc_open(ssh -o PasswordAuthentication=no user@server.org 'drush  --verbose --root=/srv/www/drupal/htdocs --uri=http://site.org  sql-conf 2>&1' 2>&1);

$ drush --remote-host=server.org --remote-user=user --root=/srv/www/drupal/htdocs --uri=http://site.org sql-conf

The first version, with an alias, worked, but the second invocation with cli options got confused, and tried to execute the command locally. I got the same result in 6.x and 5.x, so I guess this has been broken for a long time. I created a bug report on GitHub for this:

https://github.com/drush-ops/drush/issues/369

Fortunately, there is one more option. Drush will let you craft an alias on the command line, by combining the different elements of the alias record in a special form, "user@server/path#site". So, I did this:

$ drush user@server.org/srv/www/drupal/htdocs#site.org sql-conf -v

That worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.