Script task fails with command not found

Still need help?

The Atlassian Community is here for you.

Ask the community


Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Bamboo provides the ability to execute arbitrary commands and executables on remote or local agents. This is achieved by creating a ScriptTask and specifying the commands to be executed. The commands will then be executed within either the agent context or a specified Docker image.

If the agent is unable to find one of the referenced commands the ScriptTask will fail with command not found . The following is a sample where mycmd  was specified but not found by the agent.


$stringEscapeUtils.escapeHtml($body)


Cause

A command would show as command not found  if the shell that is trying to execute the command is unable to locate the file. The shell would normally look for commands within the directories listed in the PATH environment variable. Hence if the directory list specified by PATH does not contain the directory where the command is located the shell will fail to find it.

  • A local agent context will inherit the PATH  specified when Bamboo was started.
  • A remote agent context will inherit the PATH  specified when the remote agent was started.
  • If the job specified that it should be executed in a docker context; the PATH would be the default PATH for the specified docker image.

Resolution

The resolution for the issue is to ensure that the command/executable is accessible by the Bamboo agent

  • The command exists on the system or within the docker  image being used.
  • The directory containing the command is included within the PATH environment variable used. 
  • The command file is executable and has access permissions granting access to the user running the Bamboo agent.



Last modified on Sep 20, 2021

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.