Troubleshooting Builds

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.

Builds in Bamboo are exactly the same as how they would be executed via the command line.


Bamboo Build Process

Bamboo forks a new process for each build and tries to reproduce the user's environment by passing down all the System and PATH variables to the build.

The new process is created using the Apache Ant Execute Task as below:

Click here to expand...
AbstractBuilder.java
    /**
     * Execute the command line in a specific directory.
     *
     * @param buildContext The BuildContext for the current build
     * @param commandExecuteStreamHandler Stream Handler for the output of the execute command
     * @param extraEnvironmentVariables environment variable additional to those already in the env (e.g provided by the user via UI)
     * @param javaHome The java home value for this command
     * @param capabilitySet Capability set
     * @return -1 if the command failed
     * @throws CommandException Failure
     */
    public int executeCommand(final @NotNull BuildContext buildContext, final @NotNull CommandExecuteStreamHandler commandExecuteStreamHandler, String extraEnvironmentVariables, String javaHome, ReadOnlyCapabilitySet capabilitySet) throws CommandException
    {
        final BuildLogger buildLogger = buildLoggerManager.getBuildLogger(buildContext.getBuildResultKey());

        Commandline commandline = getSubstitutedCommandLine(buildContext, buildLogger, capabilitySet);

        extraEnvironmentVariables = substitutionBean.substituteBambooVariables(extraEnvironmentVariables, buildContext, buildLogger);

        Execute execute = new Execute(commandExecuteStreamHandler);
        execute.setWorkingDirectory(getWorkingDirectory());
        execute.setCommandline(commandline.getCommandline());

        String[] defaultEnvironmentVars = getEnvironmentSetting(extraEnvironmentVariables, javaHome);

        String[] customEnvironmentVars = getCustomEnvironmentVars(capabilitySet);
        if (customEnvironmentVars != null && customEnvironmentVars.length > 0)
        {
            defaultEnvironmentVars = (String[]) ArrayUtils.addAll(defaultEnvironmentVars, customEnvironmentVars);
        }

        execute.setEnvironment(defaultEnvironmentVars);

        checkHomeVariable(execute);

        if (ArrayUtils.contains(defaultEnvironmentVars, "BAMBOO_DEBUG_BUILD=true"))
        {
            debugBuildEnvironment(buildContext, buildLogger, execute);
        }

        try
        {
            return execute.execute();
        }
        catch (Exception e)
        {
            log.warn("Failed to execute command", e);
            throw new CommandException(e.getMessage(), e);
        }
    }

Debugging Failing Builds

If you haven't done so already, please run your build outside of Bamboo via the command line as the user running the Bamboo process and confirm that build is successful.

Navigate to your working directory and run the build manually:

Local Agents:

  • Bamboo 7 or earlier: <bamboo-home>/xml-data/build-dir/PLAN_KEY
  • Bamboo 8 or newer: <bamboo-home>/local-working-dir/build-dir/PLAN_KEY

Remote or Elastic Agents:

  • <bamboo-agent-home>/xml-data/build-dir/PLAN_KEY


For example, if this is a Maven build then please supply the appropriate goal: mvn clean install

Please ensure that the following criteria have been met:

  • Ensure that Bamboo is running as the local user and the user executing the build via the command line owns the Bamboo process.

    Bamboo Service on Windows

    Bamboo will install itself as the SYSTEM user on Windows, ensure that you are running the Bamboo service as the local user

  • If the failing build is being executed on a remote or elastic agent, ensure that it can be executed successfully on the agent as the Bamboo user.
  • If your build has specific dependencies or requires you to set Environment Variables, ensure that the variables/dependencies are available to your build.
  • If your JAVA build is failing due to memory errors, then please try increasing the memory allocated to your build.

Check the build agent logs:

You may find additional information about the reason for the failure in the Agent logs.

Local Agents:

  • <bamboo-home>/logs/atlassian-bamboo.log

Remote or Elastic Agents:

  • <bamboo-agent-home>/atlassian-bamboo-agent.log
  • <bamboo-agent-home>/logs/atlassian-bamboo.log


Last modified on Mar 23, 2022

Was this helpful?

Yes
No
Provide feedback about this article

In this section

Powered by Confluence and Scroll Viewport.