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

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. 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:

    1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 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):

1 2 3 4 5 6 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 URLhttps://<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.

Updated on March 13, 2025

Still need help?

The Atlassian Community is here for you.