Docker runner build will fail when command task is used and the executable is not present on the agent as a capability

XMLWordPrintable

    • Severity 3 - Minor

      Summary

      Docker runner builds will fail when the build has a command-task and the executable is not listed as a capability on the remote or elastic agent running the build.

      Steps to Reproduce

      1. Create a plan with a Command Task:
        • Add new executable:
        • Executable label: Bash
        • Path: /bin/bash
        • Argument: -c 'echo hello!'
      2. Job Configuration >> Docker >> Docker container >> ubuntu:xenial
      3. Dedicate the plan to a remote agent (that does not have the capability 'Bash') with Docker
      4. Run the build

      Expected Results

      Build succeeds

      Actual Results

      The below error is shown in the build log

      Elastic Agent:
      simple	12-Mar-2018 12:39:03	Starting task 'Echo hello' of type 'com.atlassian.bamboo.plugins.scripttask:task.builder.command'
      command	12-Mar-2018 12:39:03	Beginning to execute external process for build 'PROJ - PLAN - TEST - Build #11 (PLAN-BUILD-KEY)'\n ... running command line: \n/tmp/runInDocker5637298090231688207.sh  -c echo hello!\n ... in: /tmp\n
      error	12-Mar-2018 12:39:03	Error occurred while running Task 'Command' of type com.atlassian.bamboo.plugins.scripttask:task.builder.command.
      error	12-Mar-2018 12:39:03	com.atlassian.bamboo.task.TaskException: Failed to execute task
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.plugins.shell.task.AbstractShellBuildTask.execute(AbstractShellBuildTask.java:63)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.plugins.shell.task.AbstractShellBuildTask.execute(AbstractShellBuildTask.java:37)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$3(TaskExecutorImpl.java:285)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:224)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:285)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:112)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:71)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.executeBuildPhase(DefaultBuildAgent.java:203)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:175)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.lambda$waitAndPerformBuild$0(BuildAgentControllerImpl.java:122)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:185)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:117)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:126)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41)
      error	12-Mar-2018 12:39:03		at java.lang.Thread.run(Thread.java:748)
      error	12-Mar-2018 12:39:03	Caused by: java.lang.NullPointerException
      error	12-Mar-2018 12:39:03		at java.lang.ProcessBuilder.start(ProcessBuilder.java:1012)
      error	12-Mar-2018 12:39:03		at com.atlassian.utils.process.ExternalProcessImpl.createDefaultProcess(ExternalProcessImpl.java:377)
      error	12-Mar-2018 12:39:03		at com.atlassian.utils.process.ExternalProcessImpl.createProcess(ExternalProcessImpl.java:385)
      error	12-Mar-2018 12:39:03		at com.atlassian.utils.process.ExternalProcessImpl.start(ExternalProcessImpl.java:339)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.process.ProcessServiceImpl.executeExternalProcess(ProcessServiceImpl.java:192)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.process.ProcessServiceImpl.executeExternalProcess(ProcessServiceImpl.java:206)
      error	12-Mar-2018 12:39:03		at com.atlassian.bamboo.plugins.shell.task.AbstractShellBuildTask.execute(AbstractShellBuildTask.java:46)
      error	12-Mar-2018 12:39:03		... 17 more
      
      Remote Agent:
      simple	06-Apr-2018 17:06:57	Starting task 'Command' of type 'com.atlassian.bamboo.plugins.scripttask:task.builder.command'
      command	06-Apr-2018 17:06:57	Beginning to execute external process for build 'PLAN - COMMAND - Default Job #28 (PLAN-COMM-JOB1-28)'\n ... running command line: \n/var/folders/3r/s8xj50_127j8r1t0qbd7x_fmg353p4/T/copyAndExec1397308028266437928.sh\n ... in: /var/folders/3r/s8xj50_127j8r1t0qbd7x_fmg353p4/T\n
      error	06-Apr-2018 17:06:58	/tmp/runInDocker9035046863930505458.sh: 4: /tmp/runInDocker9035046863930505458.sh: null: not found
      simple	06-Apr-2018 17:06:58	Failing task since return code of [/var/folders/3r/s8xj50_127j8r1t0qbd7x_fmg353p4/T/copyAndExec1397308028266437928.sh] was 127 while expected 0
      simple	06-Apr-2018 17:06:58	Finished task 'Command' with result: Failed
      

      Workaround

      Add a matching Command executable capability to the Agent at:

      • Bamboo Administration >> Agents >> agent >> Add capability (for Remote Agent)
      • Bamboo Administration >> Image Configurations >> image >> Add capability (for Elastic Agent)

            Assignee:
            Grzegorz Lewandowski
            Reporter:
            Jeremy Owen
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: