Kondiba
Kondiba

Reputation: 93

Using jenkins wanted to copy some script file to /bin/

Using jenkins I have created one job and I have script files in git and i wanted to copy in /bin/. I have tried using sudo. I have tried to copy from jenkins workspace to bin but unable to copy

echo 'password'|sudo cp -S /var/lib/jenkins/workspace/WiCheck_project/sample.sh /bin/

but it it giving following error.

[sudo] password for jenkins: Sorry, try again.
[sudo] password for jenkins: 
sudo: 1 incorrect password attempt
Build step 'Execute shell' marked build as failure

Please help me how to use sudo to copy files.

Upvotes: 0

Views: 532

Answers (1)

burnettk
burnettk

Reputation: 14037

it's asking for your password to run sudo. you could use expect to inject it if you hate yourself.

or, if you have access to the slave, you could read about sudoers and update the sudoers file or add a file to sudoers.d to allow the jenkins user to run sudo cp passwordless.

or you could chown the /bin directory to the jenkins user so you don't have to use sudo.

or, the best option, just use ./WiCHeck_project/sample.sh to run your script instead of sample.sh, so it won't have to be in /bin.

Upvotes: 1

Related Questions