Execution a deployment script on a remote ssh server through a Jenkins pipeline

Viewed 2511

I've got a Jenkins pipeline containing stages for source loading, building and deploying on a remote machine through SSH. The problem is about the last one. I saved the script of the following template on the remote server:

#!/bin/bash
bash /<pathTo>/jboss-cli.sh --command="deploy /<anotherPath>/service.war --force"

It works fine if executed in a terminal connected to the remote server.

The best outcome I've received through Jenkins is

/<pathTo>/jboss-cli.sh: line 87: usr/bin/java/bin/java: No such file or directory

in Jenkins console output.

Tried switching between bash and sh, exporting path to java in the pipeline script etc.

Any suggestions are appreciated. Thanks!

p.s. Execution call from Jenkins looks like:

sh """
ssh -o StrictHostKeyChecking=no $connectionName 'bash /<pathToTheScript>/<scriptName>.sh'
"""
1 Answers
Related