0

When i try to deploy my jar file from jenkins located in AWS Instance to mule standalone server , i am facing the below issue. Please help me in resolving it.

+ sudo su- cp /var/lib/jenkins/workspace/Addition/addition/target/addition-1.0.0-SNAPSHOT-mule-application.jar /home/ec2-user/mate/mule-enterprise-standalone-4.3.0/apps

We trust you have received the usual lecture from the local System
Administrator. It usually boils down to these three things:

    #1) Respect the privacy of others.
    #2) Think before you type.
    #3) With great power comes great responsibility.

sudo: no tty present and no askpass program specified
Build step 'Execute shell' marked build as failure
Finished: FAILURE

enter image description here

aled
  • 21,330
  • 3
  • 27
  • 34
  • Did you solve your problem? Share us the jenkins job you have used! Also I can suggest you another ways a little better to deploy mule apps! – JRichardsz May 25 '20 at 02:17

4 Answers4

0

It maybe your mistype or not cut&paste but I believe you have wrong command su- It looks like it messes with you command and sudo does not see command at all.

If you need su then it should be su - but I do not believe you need one at all.

You just copy file already as root (because of sudo) you don't need to be root again.

Some advice. Listen for system messages - don't use root access. Adjust your privileges/groups/permissions so your process can write to this directory without root access. Second, since it is partially cloud and network is potentially slow - do not copy directly to apps folder. Copy to temporary location on the same file system where apps is and then move file to aps.

Mule runtime checks apps folder every 5 seconds for new apps. If file is not comleteley copied it could damage deployed app.

Alex
  • 4,457
  • 2
  • 20
  • 59
0

The error is caused by incorrect setting of permissions, and was actually asked before at How to fix 'sudo: no tty present and no askpass program specified' error?

Having said that, using root access for building and deployment is actually a bad security practice and should be avoided. You could use sudo -u USER for a specific user. In your command line I can see the script is deploying to the home directory of user ec2-user, so you should be using that one to limit access.

aled
  • 21,330
  • 3
  • 27
  • 34
  • Hi Aled,Alex... I tried with sudo, sudo su - , sudo su ec2-user, sudo -u ec2-user.... but still i am facing the issue. but i execute the same commands form terminal , i am able to move the file. sudo cp '/var/lib/jenkins/workspace/Maven_add/addition/target/addition-1.0.0-SNAPSHOT-mule-application.jar' /home/ec2-user/Downloads/mule-enterprise-standalone-4.3.0/apps – user1543516 May 26 '20 at 14:06
  • Are you executing the command from the terminal with exactly the same user than Jenkins? – aled May 26 '20 at 15:10
  • yes... as a ec2-user i am able to copy data from source to target by using the below command. – user1543516 May 26 '20 at 15:29
  • sudo cp '/var/lib/jenkins/workspace/Maven_add/addition/target/addition-1.0.0-SNAPSHOT-mule-application.jar' /home/ec2-user/Downloads/mule-enterprise-standalone-4.3.0/apps – user1543516 May 26 '20 at 15:29
  • If Jenkins is using user ec2-user, what does it need the sudo for? – aled May 26 '20 at 17:09
0

The image is from the linux terminal. But, if i execute the same in the jenkins shell , it is the throwing the error

0

Issue is resolved , Problem is not with the command.But with the jenkins... Just by following below 2 steps , issue is resolved.

sudo visudo jenkins ALL=(ALL) NOPASSWD: ALL