I can reproduce this. I run:
sshCommand remote: remote, pty: true, command: 'nohup java -jar demo.jar > nohup.out &'
And the Jenkins job runs successfully, but the Java jar is not running. I can run the command manually on the server though.
If I remove the &, it runs the Java jar successfully, but the command obviously never completes because we're not running it in the background, so the Jenkins job hangs on that step.
I also tried putting the command in a script file and running it with sshCommand, but it has the same problem.
For what it's worth, I was able to run this command using a different plugin, the Publish Over SSH plugin:
sshTransfer(
execCommand: 'nohup java -jar demo-0.0.1-SNAPSHOT.jar > nohup.out &',
removePrefix: 'target',
sourceFiles: 'demo.jar'),
So I could get the desired behaviour by mixing and matching the plugins, but that's not ideal. The SSH Steps plugin has better support for sudo.
Can you debug more and provide some inputs, like can you try run that command without sudo and see if that works, or try some other command and provide more information?