Repository Source Code Checkout task fails: Task was canceled

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

The purpose of this article is to troubleshoot the error message "Task was canceled - '(2)' of type com.atlassian.bamboo.plugins.vcs:task.vcs.checkout." when a plan has a Source Code Checkout task failing.

Environment

All Bamboo versions.

Diagnosis

The Source Code Checkout is a task used to check out a repository for use by just one job. By default, repositories are checked out to the Bamboo working directory. Therefore the repositories uses Git checkout to perform this action.

If you have a plan with a Source Code Checkout task failing and see the error message "Task was canceled - '(2)' of type com.atlassian.bamboo.plugins.vcs:task.vcs.checkout." in the build logs, also check the atlassian-bamboo.log (<bamboo-home>/logs/atlassian-bamboo.log) and you may see that the build plan reported itself as "completed" but the build actually failed or it just fails completely. 

<bamboo-home>/logs/atlassian-bamboo.log
INFO [7-DelayedChangeDetectionThread:pool-13-thread-3] [ChainExecutionManagerImpl] Build PROJ-REG-JOB1-14 has been dispatched
INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-56] [BuildQueueManagerImpl] Attempting to queue Proj Test - Default Job #14 (PROJ-REG-JOB1-14).
INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-56] [ExecutionPhaseServiceImpl] Proj Test - Default Job #14 (PROJ-REG-JOB1-14) queued
[...]
INFO [ActiveMQ Session Task-27021] [ExecutionPhaseServiceImpl] Proj Test - Default Job #14 (PROJ-REG-JOB1-14) sent to agent 2195457 
INFO [ActiveMQ Session Task-27021] [CurrentlyBuildingContainer] startBuildingOnAgent called for [PROJ-REG-JOB1-14], agent 2195457
INFO [9-BuildTailMessageProcessingThread-expensive:pool-15-thread-3] [LocalBuildResultProcessor] Processing build result PROJ-REG-JOB1-14...
INFO [9-BuildTailMessageProcessingThread-expensive:pool-15-thread-3] [ExecutionPhaseServiceImpl] Proj Test - Default Job #14 (PROJ-REG-JOB1-14) execution finished
WARN [9-BuildTailMessageProcessingThread-expensive:pool-15-thread-3] [CurrentlyBuildingImpl] PROJ-REG-JOB1-14: timer being stopped, but timer isn't started
INFO [9-BuildTailMessageProcessingThread-expensive:pool-15-thread-3] [PlanStatePersisterImpl] PROJ-REG-JOB1-14: Generating build results summary...
INFO [9-BuildTailMessageProcessingThread-expensive:pool-15-thread-3] [PlanStatePersisterImpl] Updating delta states of build following PROJ-REG-JOB1-14
INFO [9-BuildTailMessageProcessingThread-expensive:pool-15-thread-3] [CurrentlyBuildingContainer] removeCurrentlyBuilding called for [PROJ-REG-JOB1-14]
INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-48] [BuildCompletedEventListener] Running build post actions 'PROJ-REG-JOB1-14'
INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-35] [ChainExecutionManagerImpl] Plan PROJ-REG-JOB1-14: Proj Test e has finished executing
INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-33] [EnvironmentDependencyListener] Deployments not triggered since chain stage failed
INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-35] [PlanStatePersisterImpl] Updating delta states of build following PROJ-REG-14
INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-35] [PostChainIndexAction] Indexing PROJ-REG-14
INFO [24-IndexerService.indexer:pool-42-thread-1] [DefaultBuildResultsIndexer] Indexed PROJ-REG-JOB1-14
INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-6] [DependencyChainListener] Checking children plans of [PROJ-REG] for plan PROJ-REG-14
INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-6] [DependencyChainListener] Dependant builds not checked since plan failed
INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-6] [DependencyChainListener] Finished checking children plans of 'Proj Test' for plan PROJ-REG-14
INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-7] [EnvironmentDependencyListener] Deployments not triggered since chain failed
WARN [10-BAM::PlanExec:pool-16-thread-3] [CacheAwareness] Inheriting disabledCaches:[com.atlassian.bamboo.CHANGE_DETECTION]
INFO [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-35] [BitbucketServerBuildStatusUpdater] Sending build notification to Stash (build key: PROJ-REG-14, repository: Test)
INFO [24-IndexerService.indexer:pool-42-thread-1] [DefaultBuildResultsIndexer] Indexed PROJ-REG-14
<atlassian-bamboo-agent>/logs/atlassian-bamboo-agent.log
2022-06-30 23:11:46,207 INFO [4-BAM::bambooAgent711 (2)::Agent:pool-7-thread-1] [VcsCheckoutTask] Updating source code to revision: 2a7cbe6b21062ffdba0904bc5b879e66290337a6
2022-06-30 23:11:46,212 INFO [4-BAM::bambooAgent711 (2)::Agent:pool-7-thread-1] [RetryingTaskExecutor] Task 'Retrieving source for Project - Regions - Default Job #12 (PROJ-REG-JOB1-12)' was unsuccessful. Run 2 / 2. Exception thrown when running task 'Retrieving source for Project - Regions - Default Job #12 (PROJ-REG-JOB1-12)', with message: null
2022-06-30 23:11:46,212 ERROR [4-BAM::bambooAgent711 (2)::Agent:pool-7-thread-1] [RetryingTaskExecutor] Failed to run task 'Retrieving source for Project - Default Job #12 (PROJ-REG-JOB1-12)' after 2 attempts. Task was not executed. Rethrowing exception.
2022-06-30 23:11:46,213 FATAL [4-BAM::bambooAgent711 (2)::Agent:pool-7-thread-1] [PrepareBuildTask] Failed to prepare the build 'Project - Default Job #12 (PROJ-REG-JOB1-12)'
2022-06-30 23:11:46,217 INFO [4-BAM::bambooAgent711 (2)::Agent:pool-7-thread-1] [DefaultBuildAgent] Detected '1' errors in build. Aborting build process.
2022-06-30 23:11:46,223 INFO [4-BAM::bambooAgent711 (2)::Agent:pool-7-thread-1] [AbstractArtifactManager] Publishing [LogsFromBambooAgent] for PROJ-REG-JOB1-12: 1 file(s) matching [plan-1507329-JOB1-12.log] in directory /home/bamboo/bamboo-agent-home/temp/log_spool
2022-06-30 23:11:46,227 INFO [4-BAM::bambooAgent711 (2)::Agent:pool-7-thread-1] [AbstractArtifactManager] Trying to publish the artifact with handler: com.atlassian.bamboo.build.artifact.BambooRemoteArtifactHandler
2022-06-30 23:11:46,239 INFO [4-BAM::bambooAgent711 (2)::Agent:pool-7-thread-1] [BambooArtifactHttpTransport] Finished writing the artifact to the output stream, time elapsed: 2.460 ms
2022-06-30 23:11:46,264 INFO [4-BAM::bambooAgent711 (2)::Agent:pool-7-thread-1] [AbstractArtifactManager] Handler com.atlassian.bamboo.build.artifact.BambooRemoteArtifactHandler published the artifact, size: 1 KB, time elapsed: 36.82 ms
2022-06-30 23:11:46,275 INFO [4-BAM::bambooAgent711 (2)::Agent:pool-7-thread-1] [BuildAgentControllerImpl] Dumping context to file: /home/bamboo/bamboo-agent-home/xml-data/build-dir/build-result.xml
2022-06-30 23:11:46,336 INFO [4-BAM::bambooAgent711 (2)::Agent:pool-7-thread-1] [RemoteResultProcessor] Build Project - Default Job #12 (PROJ-REG-JOB1-12) completed on Bamboo agent. Sending results to server.
Build plan log
simple	30-Jun-2022 23:11:45	Build Project - Regions - Default Job #12 (PROJ-REG-JOB1-12) started building on agent bambooAgent711 (2), bamboo version: 8.1.1
simple	30-Jun-2022 23:11:45	Remote agent on host bambooAgent711
simple	30-Jun-2022 23:11:45	Build working directory is /home/bamboo/bamboo-agent-home/xml-data/build-dir/PROJ-REG-JOB1
simple	30-Jun-2022 23:11:45	Executing build Project - Regions - Default Job #12 (PROJ-REG-JOB1-12)
simple	30-Jun-2022 23:11:45	Starting task 'Source Code Checkout' of type 'com.atlassian.bamboo.plugins.vcs:task.vcs.checkout'
simple	30-Jun-2022 23:11:45	Checking out into /home/bamboo/bamboo-agent-home/xml-data/build-dir/PROJ-REG-JOB1
simple	30-Jun-2022 23:11:45	Updating source code to revision: 2a7cbe6b21062ffdba0904bc5b879e66290337a6
simple	30-Jun-2022 23:11:46	Task was canceled - '(2)' of type com.atlassian.bamboo.plugins.vcs:task.vcs.checkout.
error	30-Jun-2022 23:11:46	Failed to prepare the build 'Project - Regions - Default Job #12 (PROJ-REG-JOB1-12)'

Note that looking at the logs such as atlassian-bamboo.log, atlassian-bamboo-agent.log or the build log from the UI, we cannot tell what is causing the build plan to fail. 

Troubleshooting further

To troubleshoot this issue we need to enable certain log4j  debug classes on the remote agent to investigate Git. Please follow the documentation below on how to enable the debug classes below:

For Bamboo versions prior 9

<bambo-agent-home>/conf/log4j.properties
log4j.rootLogger=INFO, console
log4j.appender.console=org.apache.log4j.ConsoleAppender
log4j.appender.console.layout=org.apache.log4j.PatternLayout
log4j.appender.console.layout.ConversionPattern=%d %p [%t] [%c{1}] %m%n
log4j.category.org.apache.sshd=DEBUG
log4j.category.com.atlassian.bamboo.plugins.git.GitCommandProcessor=DEBUG
log4j.category.com.atlassian.bamboo.plugins.git.NativeGitOperationHelper=DEBUG

After enabling the debug classes inside the log4j.properties file, add the absolute path where it is saved inside the wrapper.conf file of the agent and restart the agent.

<bamboo-agent-home>/conf/wrapper.conf
wrapper.java.additional.3=-Dlog4j.configuration=<bamboo-agent-home>/conf/log4j.properties

For Bamboo version 9 and above

<bambo-agent-home>/conf/log4j2.properties
logger.sshd.level=DEBUG
logger.sshd.name=org.apache.sshd

logger.gitcomm.level=DEBUG
logger.gitcomm.name=com.atlassian.bamboo.plugins.git.GitCommandProcessor

logger.nativegit.level=DEBUG
logger.nativegit.name=com.atlassian.bamboo.plugins.git.NativeGitOperationHelper

After enabling the debug classes inside the log4j2.properties file, add the absolute path where it is saved inside the wrapper.conf file of the agent and restart the agent.

<bamboo-agent-home>/conf/wrapper.conf
wrapper.java.additional.3=-Dlog4j2.configurationFile=<bamboo-agent-home>/conf/log4j2.properties

Once the debug classes are enabled in the agent, run the build one more time and check the build logs. We should see an extra line just like the one below, giving us the error:

DEBUG [0-BAM::bambooAgent723::Agent:pool-3-thread-1] [GitCommandProcessor] Running in /: [/usr/bin/git version]

Cause

This occurs due to the agent capability git path pointing to the incorrect directory where git is installed or running an unsupported git version. Please check the supported version according to our Bamboo Support Platforms.

Solution 1:

  1. Check the git version on the server and remote agent.
  2. Edit the agent capability by adding the correct git path Cog > Agents > click to open the agent running the build plan > find the Git capability > click Edit > Add the correct Git path.

Solution 2:

  1. Save the repository used in the Source code checkout task from Bamboo UI > Repository Configuration > Save.
  2. Restart the Bamboo agent to update the capabilities of the agent on the Bamboo server.



Last modified on Mar 5, 2024

Was this helpful?

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