How to execute command lines as root in a Hudson job?

383 views Asked by At

In Hudson, I created a job that try to execute this command line in an Ubuntu Hudson Slave :

sudo mount -t cifs //path/to/network/directory /path/to/local/directory -o username=<Account>,password=<AccountPassword>,domain=<DomaineName>

But I get this error :

sudo: no tty present and no askpass program specified

Then, I try to execute this command line in the Hudson job instead :

mount -t cifs //path/to/network/directory /path/to/local/directory -o username=<Account>,password=<AccountPassword>,domain=<DomaineName>

Then, I get this error :

mount: only root can do that

Then I tried this command line (I tried it because this command work in putty):

ssh "sudo mount -t cifs //path/to/network/directory /path/to/local/directory -o username=<Account>,password=<AccountPassword>,domain=<DomaineName>"

But I failed by this error :

ssh: Could not resolve hostname ,domain=<DomaineName>: Name or service not known

After reading this I tried to resolve the previous error by executing this command line in the Ubuntu terminal :

sudo chmod a+s /sbin/mount.cifs

But this didn't resolve my problem.

This didn't work either :

mount.cifs //path/to/network/directory /path/to/local/directory -o username=<Account>,password=<AccountPassword>,domain=<DomaineName>

Should I get the way to authenticate as root in the Hudson job (password should be set at an automatic way)? Or should I give root privileges to Hudson user?

How can I resolve this problem?

Thank you a lot!

1

There are 1 answers

2
Guntram Blohm On BEST ANSWER

Best thing to do is probably add the mount to /etc/fstab and specify the "user" option, so you don't have to be root to do the mount.

The line you add to /etc/fstab should look like this:

//path/to/network/directory /path/to/local/directory cifs noauto,user,username=<account>,password=<password>,domain=<domain> 0 0