Bamboo SCP task fails with "java.lang.NullPointerException" error when uploading a shared artifact

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

When using the Bamboo SCP task to upload a shared artifact from Bamboo directly to a remote server, the task fails a "java.lang.NullPointerException" error that is shown on the build log.

Environment

Bamboo Server or Data Center

Diagnosis

  1. Add a SCP task to your plan and select a shared artifact as your file to be transferred
  2. Run your plan
  3. In your build logs you can find the below error and stack trace:

    simple	08-Jul-2021 14:04:02	Starting task 'Publish Release Notes' of type 'com.atlassian.********.plugins.********-scp-plugin:scptask'
    error	08-Jul-2021 14:04:02	Error occurred while running Task 'Publish Release Notes(10)' of type com.atlassian.********.plugins.********-scp-plugin:scptask.
    error	08-Jul-2021 14:04:02	java.lang.NullPointerException
    error	08-Jul-2021 14:04:02		at java.io.File.<init>(File.java:362)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.plugins.scp.ScpTask$CopyPathSpecs.<init>(ScpTask.java:80)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.plugins.scp.ScpTask.getPathSpecToCopy(ScpTask.java:153)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.plugins.scp.ScpTask.run(ScpTask.java:117)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.plugins.scp.ScpTask.execute(ScpTask.java:106)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.task.TaskExecutorImpl.lambda$executeTasks$2(TaskExecutorImpl.java:317)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:252)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:317)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.task.TaskExecutorImpl.execute(TaskExecutorImpl.java:112)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.build.pipeline.tasks.ExecuteBuildTask.call(ExecuteBuildTask.java:73)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.v2.build.agent.DefaultBuildAgent.executeBuildPhase(DefaultBuildAgent.java:204)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:176)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.v2.build.agent.BuildAgentControllerImpl.lambda$waitAndPerformBuild$0(BuildAgentControllerImpl.java:131)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:185)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:125)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:127)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.utils.BambooRunnables$1.run(BambooRunnables.java:48)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)
    error	08-Jul-2021 14:04:02		at com.atlassian.********.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41)
    error	08-Jul-2021 14:04:02		at java.lang.Thread.run(Thread.java:748)

Cause


The artifact_definition table, used to store the definition of all your artifacts, has several columns for storing artifact name, pattern, location and so forth. When column src_directory on that table is NULL the SCP Task fails and throws the above errors when trying to fetch the artifact definition data. The reason why that column is NULL not yet known. To confirm if that's the case on your instance you can run the below query (please make sure to replace the build key with your own one:

select *
  from artifact_definition ad
  join build b
    on ad.producer_job_id = b.build_id
 where b.full_key = 'PROJ-PLAN-JOB'
   and ad.src_directory is null;

Solution

  1. Access your Bamboo instance URL https://<your-bamboo-URL>/build/admin/edit/defaultBuildArtifact.action?buildKey=PROJ-PLAN-JOB page and re-save the artifact definition for the artifact the shared artifact that you are using on your SCP task.
  2. Run your affected plan and confirm that the error is gone.

Last modified on Jul 19, 2021

Was this helpful?

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