How to run jar file from Jenkins to EC2 remote server

0

I'm trying to run a jar file by execute shell on jenkins server to ec2 server with the following command:

ssh -i [mykey] [username]@[Ip address of the host]  java  -jar [jarname].jar'

but keep getting an error message:

"Error: Unable to access jar file Mycode.jar"

When I try to run java -jar Mycode.jar directly on the machine it works fine, just when I'm when it's done remotely, it doesn't work. Any idea?

Karin Golan

Posted 2017-10-02T16:10:41.423

Reputation: 11

Answers

0

You can execute through ssh:

ssh remote@machine.com 'java -jar hellofile.jar'

and you will see the result in the terminal

Mr. Raspberry

Posted 2017-10-02T16:10:41.423

Reputation: 385