rocketeers / rocketeer

Send your projects up in the clouds
http://rocketeer.autopergamene.eu/
MIT License
2.66k stars 217 forks source link

SVN username and password not passed to `svn co` #192

Closed marcovtwout closed 10 years ago

marcovtwout commented 10 years ago

I have setup Rocketeer to deploy using my svn repository. When I execute rocketeer deploy, I run into the following error:

Cloning repository in "/data/www/xxx/releases/20140318163638"
Unable to clone the repository
svn: E170001: Unable to connect to a repository at URL 'svn://localhost/test/trunk'

Final lines from logs/production--xxx.log:

[2014-03-18 20:36:39] rocketeer.INFO: ["svn co --non-interactive svn:\/\/localhost\/xxx\/trunk \/data\/www\/xxx\/releases\/20140318163638"] [] []
[2014-03-18 20:36:39] rocketeer.INFO: svn: E170001: Unable to connect to a repository at URL 'svn://localhost/test/trunk'
svn: E170001: Can't get username or password [] []

My scm.php looks like this:

<?php return array(
    'scm' => 'svn',
    'repository' => 'svn://localhost/test',
    'username'   => 'xxx',
    'password'   => 'xxx',
        (...)
);

When I look at the source code, the username and password should be passed to the checkout command, but as you can see in the log file, they are being omitted. https://github.com/Anahkiasen/rocketeer/blob/3591b74208e632ce5ffe090ffcd19330785feb77/src/Rocketeer/Scm/Svn.php#L80

Anahkiasen commented 10 years ago

You can send a PR to develop if you want, from what I understand it's a simple fix no ?

marcovtwout commented 10 years ago

If I understand correctly, the function getCredentials() should get username and password from scm.php. I haven't looked much deeper yet, can you see why that fails?

https://github.com/Anahkiasen/rocketeer/blob/3591b74208e632ce5ffe090ffcd19330785feb77/src/Rocketeer/Scm/Svn.php#L111 https://github.com/Anahkiasen/rocketeer/blob/cc287bee0344b64e09eb970a357387c01db327bf/src/Rocketeer/Rocketeer.php#L356

Anahkiasen commented 10 years ago

Can you try to go in artisan tinker and do app('rocketeer.rocketeer')->getCredentials() ?

marcovtwout commented 10 years ago

Sorry, I am not using Lavarel?

Anahkiasen commented 10 years ago

Then try in tasks.php or events.php to do var_dump(Rocketeer::getFacadeApplication()['rocketeer.rocketeer']->getCredentials(), see what that yields when you do rocketeer --version or something.

marcovtwout commented 10 years ago

I grabbed a copy of the source code and debugged into the following function: https://github.com/Anahkiasen/rocketeer/blob/master/src/Rocketeer/Rocketeer.php#L358

I modified it like this:

$credentials = $this->app['rocketeer.server']->getValue('credentials');
print_r($credentials);
//if (!$credentials) {
    $credentials = $this->getOption('scm');
//}
print_r($credentials);

It returns:

// first:
Array
(
    [repository] => svn://localhost/test
)

// second:
Array
(
    [scm] => svn
    [repository] => svn://localhost/test
    [username] => xxx
    [password] => xxx
    [branch] => trunk
    [shallow] => 1
    [submodules] => 1
)                                    

It seems to me we need the second piece of information. How exactly did you intend this piece of code to work?

Anahkiasen commented 10 years ago

The first one returns the data from prompt which should have been merged with the second data but hasn't been somehow which is why the condition passes but we don't have any credentials. Weird, not sure how that happened.

marcovtwout commented 10 years ago

What do you mean "from prompt". Do you mean the questions on rocketeer setup?

Anahkiasen commented 10 years ago

No I mean, if you leave a field empty, Rocketeer prompts you for its value, this is used to not have to track credentials in the Rocketeer config while still saving it somewhere safe to not ask for it everytime. That's why the config isn't used directly.

marcovtwout commented 10 years ago

Ah, right. I do not see any prompt for credentials.

marcovtwout commented 10 years ago

Note that I am using a url in the svn:// format. Does this have anything to do with it?

I also found: https://github.com/Anahkiasen/rocketeer/pull/54

Anahkiasen commented 10 years ago

Is svn:// similar to git:// ? If yes you may want to switch to HTTP cloning unless your server has SSH access to your repo.

marcovtwout commented 10 years ago

Yes and no:

The svn:// protocol provides direct access to the svn-server over port 3690, while the http protocol provides indirect access (with WebDav). This is different to svn+ssh, in which case you also require ssh access to the remote svn server. Access through the ssh protocol is faster and does not require to set up an additional webserver like Apache for the http(s) tunneling.

Concluding, like you said, Rocketeer should prompt for the username/password inputs, but does not.

PouleR commented 10 years ago

I just started using Rocketeer (in combination with Laravel) and I tried to deploy the application from my SVN server. I also ran into the problem that svn stops with the following error:

svn: Can't get username or password

My settings for the scm.php are all configured:

'scm' => 'svn', 'repository' => 'svn://[ip]:[port]/[repo]', 'username' => 'xxx', 'password' => 'xxx',

Too bad because Rocketeer seems promising, but this is blocking to deploy my application

marcovtwout commented 10 years ago

@Anahkiasen I see this bug is labeled as unverified? I think this is an important feature for svn users, do you need more information to fix the issue?

marcovtwout commented 10 years ago

Any progress on this issue?

Anahkiasen commented 10 years ago

Is this still happening on develop ?

marcovtwout commented 10 years ago

This issue is not fixed yet on latest develop with newly created config.

C:\www\test>php ..\rocketeer\bin\rocketeer deploy --verbose
-- Running: Deploy (Deploys the website)
Cloning repository in "/data/www/example.com/releases/20140812195423"
[user@example] (production#0) svn: E170001: Unable to connect to a repository at URL 'svn://example.com/test/trunk'
[user@example] (production#0) svn: E170001: Can't get username or password
Anahkiasen commented 10 years ago

Can you run that with --pretend see if the credentials flags are properly passed to svn co ?

marcovtwout commented 10 years ago

They are not passed, exactly like the earlier log in the top post describes. Username and password fields are set in scm.php.

rocketeer deploy --pretend
-- Running: Deploy (Deploys the website)
Cloning repository in "/data/www/example.com/releases/20140813181447"
svn co svn://example.com/test/trunk /data/www/example.com/releases/20140813181447 --non-interactive

Note: It does not matter if I leave the username and password in scm.php empty, I am not prompted for credentials in that case.

Anahkiasen commented 10 years ago

Should be fixed by 0e32fb3200c298e4a01ef9db254493ede90680d5, will reopen if the issue still occurs.

marcovtwout commented 10 years ago

Confirmed, thanks.

lcetinsoy commented 9 years ago

I have the same issue but for git cloning with v 2.1.2 on debian 7

I cannot manage to get the repository cloned with a password (prompted or not ):

my scm.php:


    // The SCM used (supported: "git", "svn")
    'scm'        => 'git',
    'repository' => 'user@xx.xx.xx.xx:/path/to/repo'
    'username'   => 'user',
    'password'   => ''',
    'branch'     => 'dev',
    'shallow'    => true,
    'submodules' => true,

rocketeer tries do to : git clone "user@xx.xx.xx.xx:/path/to/repo "/path/to/prod/releases/20150811190024" --branch="dev" --depth="1"

git clone "user@xx.xx.xx.xx:/path/to/repo" works on my terminal, it prompts me the password.

Kind regards