-1

I have one bash script which deploys the application inside JBoss9. It's working fine When I runs bash script from ubuntu terminal using command ./jbctl -c restart tail -f nohup.out;

But when I calls same bash script inside Jenkins - Build - Execute shell, it shows me various errors like

    ./jbctl: line 123: cat: command not found
    ./jbctl: line 123: grep: command not found
    ./jbctl: line 123: cut: command not found
    ./jbctl: line 123: sed: command not found
    ./jbctl: line 124: cat: command not found
/tmp/jenkins2547454576675677717.sh: line 10: tail: command not found
Build step 'Execute shell' marked build as failure
Finished: FAILURE

Without this jbctl.sh file, application can't be initialised. As there are bash commands inside this ./jbctl.sh file, these are not executed inside Jenkins - Build - Execute shell.

enter image description here

Is there any other way to run this jbctl.sh script inside Jenkins? Actually this is bash script.

Vishal Pachpute
  • 159
  • 1
  • 2
  • 13
  • 1
    Did you execute it from your ubuntu, or from other Jenkins agent? Also please ensure if you have the correct `$Path` variable in Jenkins (**Manage Jenkins** -> **Global Properties** -> **Environment variables** ). – biruk1230 Mar 12 '19 at 10:21
  • I am doing execution from Ubuntu – Vishal Pachpute Mar 12 '19 at 15:35

1 Answers1

0

There are two approaches to your issue:

  1. Adjust Jenkins' environment variables (prefered) as e.g. described at wiki.jenkins.io. In short: Navigate to Manage Jenkins > Global Properties > Environment variables. For more, see also SO: "modify PATH variable in jenkins master"

  2. Quick'n'dirty: Instead of cat use the full path of your command, e.g. /usr/bin/cat. You can determine this full path with entering which cat in your bash.

B--rian
  • 5,578
  • 10
  • 38
  • 89