Run Command Line Return Value 127: command not found

book

Article ID: 220468

calendar_today

Updated On:

Products

CA Release Automation - Release Operations Center (Nolio)

Issue/Introduction

We want to execute CLI command via CARA using the "Run Command Line" action, but are getting an error. 

Command:
java -cp <jar paths> <initial.Class> -parameters values 

Error By CARA :

(#1) Run Command Line action has finished successfully.
Return value: 127
Std out:
Std err: /bin/sh: java: command not found

 

Cause

The action is being executed using the impersonation. The impersonation feature is using the sudo method. The recommended method for using to impersonate users is: sudo -u $3 -S ./ActionsRunner.sh ...

However, using this method makes it so that the users ~/.bashrc isn't executed - so its environment is very generic. In this case, it cannot find java. 

Environment

Release : 6.7

Component : CA Nolio Release Automation Agent

Resolution

There are at least two ways to solve this problem. Pick one of the following:

Method One

Modify the command to include the directory where java can be found. For example:
Instead of using the command: java -cp <jar paths> <initial.Class> -parameters values 
Use: /path/to/java -cp <jar paths> <initial.Class> -parameters values 

 

Method Two

The second method involves updating two input fields of the "Run Command Line" action. 

  1. Add a list element to the input field "Environment Variables Names [String[]]". The list element name to use should be: PATH
  2. Add a list element to the input field "Environment Variables Values [String[]]". The list element value to use should be: $PATH:/path/where/to/find/java