Uploaded image for project: 'Bamboo Data Center'
  1. Bamboo Data Center
  2. BAM-21033

Initial build for new branches will not run if the repository cache is corrupted

    XMLWordPrintable

Details

    Description

      Issue Summary

      If the repository cache is corrupted in Bamboo and a new branch is created, the initial build for the plan brach.

      Steps to Reproduce

      1. Create a new plan
      2. Enable automatic branch creation selecting the "When new branch in repository is created" option.
      3. Go to the bamboo/xml-data/build-dir/_git-repositories-cache/<HASH>/.git folder for this repository and delete some files from there (keeping the .git folder}
      4. Create a new branch at the repository

      Expected Results

      Bamboo should identify the cache is corrupted during the initial build, recreate it, and retry to run the build.

      Actual Results

      The initial build greys out and the below exception is thrown in the atlassian.bamboo.log file:

      2020-08-07 18:04:56,618 ERROR [AtlassianEvent::0-BAM::EVENTS:pool-1-thread-15] [UpdateCreatingCommitInformationListener] Exception when initiating chain branch status
      java.lang.RuntimeException: com.atlassian.bamboo.plugins.stash.repository.StashRepositoryException: com.atlassian.bamboo.repository.RepositoryException: Cannot fetch branch 'refs/heads/development2' from 'ssh://git@bitbucket:7999/proj/test_cases.git' to source directory '/var/atlassian/application-data/bamboo/xml-data/build-dir/_git-repositories-cache/f9128b767ea46dc7220dc0e3d4f3c73ebd10a25c'. command [/usr/bin/git fetch ssh://af18cdd8-419e-4144-8f15-056b9465cb54@127.0.0.1:33027/proj/test_cases.git +refs/heads/development2:refs/heads/development2 --update-head-ok] failed with code 128. Working directory was [/var/atlassian/application-data/bamboo/xml-data/build-dir/_git-repositories-cache/f9128b767ea46dc7220dc0e3d4f3c73ebd10a25c]., stderr:
      fatal: not a git repository (or any parent up to mount point /var/atlassian/application-data)
      Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
      	at com.google.common.base.Throwables.propagate(Throwables.java:241)
      	at com.atlassian.bamboo.build.creation.UpdateCreatingCommitInformationListener.lambda$onChainCreatedEventInternal$0(UpdateCreatingCommitInformationListener.java:55)
      	at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:107)
      	at com.atlassian.bamboo.build.creation.UpdateCreatingCommitInformationListener.onChainCreatedEventInternal(UpdateCreatingCommitInformationListener.java:51)
      	at com.atlassian.bamboo.build.creation.UpdateCreatingCommitInformationListener.onChainCreatedEvent(UpdateCreatingCommitInformationListener.java:32)
      	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
      	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at com.atlassian.event.internal.SingleParameterMethodListenerInvoker.invoke(SingleParameterMethodListenerInvoker.java:42)
      	at com.atlassian.event.internal.AsynchronousAbleEventDispatcher.lambda$null$0(AsynchronousAbleEventDispatcher.java:37)
      	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
      	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
      	at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:48)
      	at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)
      	at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)
      	at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41)
      	at java.lang.Thread.run(Thread.java:748)
      Caused by: com.atlassian.bamboo.plugins.stash.repository.StashRepositoryException: com.atlassian.bamboo.repository.RepositoryException: Cannot fetch branch 'refs/heads/development2' from 'ssh://git@bitbucket:7999/proj/test_cases.git' to source directory '/var/atlassian/application-data/bamboo/xml-data/build-dir/_git-repositories-cache/f9128b767ea46dc7220dc0e3d4f3c73ebd10a25c'. command [/usr/bin/git fetch ssh://af18cdd8-419e-4144-8f15-056b9465cb54@127.0.0.1:33027/proj/test_cases.git +refs/heads/development2:refs/heads/development2 --update-head-ok] failed with code 128. Working directory was [/var/atlassian/application-data/bamboo/xml-data/build-dir/_git-repositories-cache/f9128b767ea46dc7220dc0e3d4f3c73ebd10a25c]., stderr:
      fatal: not a git repository (or any parent up to mount point /var/atlassian/application-data)
      Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
      	at com.atlassian.bamboo.plugins.stash.v2.BitbucketServerBranchDetector.getFirstCommitApproximation(BitbucketServerBranchDetector.java:59)
      	at com.atlassian.bamboo.plan.branch.BranchCommitInformationManagerImpl.initialiseCommitInformation(BranchCommitInformationManagerImpl.java:64)
      	at com.atlassian.bamboo.build.creation.UpdateCreatingCommitInformationListener.lambda$onChainCreatedEventInternal$0(UpdateCreatingCommitInformationListener.java:53)
      	... 16 more
      Caused by: com.atlassian.bamboo.repository.RepositoryException: Cannot fetch branch 'refs/heads/development2' from 'ssh://git@bitbucket:7999/proj/test_cases.git' to source directory '/var/atlassian/application-data/bamboo/xml-data/build-dir/_git-repositories-cache/f9128b767ea46dc7220dc0e3d4f3c73ebd10a25c'. command [/usr/bin/git fetch ssh://af18cdd8-419e-4144-8f15-056b9465cb54@127.0.0.1:33027/proj/test_cases.git +refs/heads/development2:refs/heads/development2 --update-head-ok] failed with code 128. Working directory was [/var/atlassian/application-data/bamboo/xml-data/build-dir/_git-repositories-cache/f9128b767ea46dc7220dc0e3d4f3c73ebd10a25c]., stderr:
      fatal: not a git repository (or any parent up to mount point /var/atlassian/application-data)
      Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
      	at com.atlassian.bamboo.plugins.git.NativeGitOperationHelper.fetch(NativeGitOperationHelper.java:544)
      	at com.atlassian.bamboo.plugins.git.v2.GitBranchDetector.lambda$getLastCommit$1(GitBranchDetector.java:91)
      	at io.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:284)
      	at com.atlassian.bamboo.plugins.git.v2.GitBranchDetector.getLastCommit(GitBranchDetector.java:82)
      	at com.atlassian.bamboo.plugins.git.v2.GitBranchDetector.lambda$getFirstCommitApproximation$0(GitBranchDetector.java:62)
      	at io.atlassian.util.concurrent.ManagedLocks$ManagedLockImpl.withLock(ManagedLocks.java:284)
      	at com.atlassian.bamboo.plugins.git.v2.GitBranchDetector.getFirstCommitApproximation(GitBranchDetector.java:57)
      	at com.atlassian.bamboo.plugins.stash.v2.BitbucketServerBranchDetector.getFirstCommitApproximation(BitbucketServerBranchDetector.java:55)
      	... 18 more
      Caused by: com.atlassian.bamboo.plugins.git.GitCommandException: command [/usr/bin/git fetch ssh://af18cdd8-419e-4144-8f15-056b9465cb54@127.0.0.1:33027/proj/test_cases.git +refs/heads/development2:refs/heads/development2 --update-head-ok] failed with code 128. Working directory was [/var/atlassian/application-data/bamboo/xml-data/build-dir/_git-repositories-cache/f9128b767ea46dc7220dc0e3d4f3c73ebd10a25c]., stderr:
      fatal: not a git repository (or any parent up to mount point /var/atlassian/application-data)
      Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
      	at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runCommand(GitCommandProcessor.java:729)
      	at com.atlassian.bamboo.plugins.git.GitCommandProcessor.runFetchCommand(GitCommandProcessor.java:310)
      	at com.atlassian.bamboo.plugins.git.NativeGitOperationHelper.fetch(NativeGitOperationHelper.java:527)
      	... 25 more
      

      then, the change detection will also identify the problem:

      2020-08-07 18:04:56,729 ERROR [7-DelayedChangeDetectionThread:pool-13-thread-4] [ChainExecutionManagerImpl] Errors getting changes for PROJ-TC2-1
      com.atlassian.bamboo.repository.RepositoryException: com.atlassian.bamboo.plugins.stash.repository.StashRepositoryException: com.atlassian.bamboo.repository.RepositoryException: : Cannot fetch branch 'refs/heads/development2' from 'ssh://git@bitbucket:7999/proj/test_cases.git' to source directory '/var/atlassian/application-data/bamboo/xml-data/build-dir/_git-repositories-cache/f9128b767ea46dc7220dc0e3d4f3c73ebd10a25c'. command [/usr/bin/git fetch ssh://7aa2b9bb-b978-428b-991a-cae21aa04ac6@127.0.0.1:33027/proj/test_cases.git +refs/heads/development2:refs/heads/development2 --update-head-ok] failed with code 128. Working directory was [/var/atlassian/application-data/bamboo/xml-data/build-dir/_git-repositories-cache/f9128b767ea46dc7220dc0e3d4f3c73ebd10a25c]., stderr:
      fatal: not a git repository (or any parent up to mount point /var/atlassian/application-data)
      Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
      	at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectInitialStateForBranchBuild(DefaultChangeDetectionManager.java:364)
      	at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectAllChangesSinceLastBuild(DefaultChangeDetectionManager.java:160)
      	at com.atlassian.bamboo.v2.trigger.DefaultChangeDetectionManager.collectAllChangesSinceLastBuild(DefaultChangeDetectionManager.java:190)
      	at com.atlassian.bamboo.build.BuildDetectionActionFactoryImpl$InitialBuildDetectionAction.performDelayedChangeDetection(BuildDetectionActionFactoryImpl.java:230)
      	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl$1.getChainState(ChainExecutionManagerImpl.java:250)
      	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.tryStartChainState(ChainExecutionManagerImpl.java:322)
      	at com.atlassian.bamboo.chains.ChainExecutionManagerImpl.delayedStart(ChainExecutionManagerImpl.java:242)
      	at sun.reflect.GeneratedMethodAccessor2198.invoke(Unknown Source)
      	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
      	at java.lang.reflect.Method.invoke(Method.java:498)
      	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:343)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:198)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:163)
      	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:93)
      	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:186)
      	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:212)
      	at com.sun.proxy.$Proxy239.delayedStart(Unknown Source)
      

      And finally the cache is deleted:

      2020-08-07 18:11:40,513 WARN [20-BAM::Agente 3::Agent:pool-43-thread-1] [AbstractGitExecutor] Deleting git workspace /var/atlassian/application-data/bamboo/xml-data/build-dir/_git-repositories-cache/95acacd8e4e70cecfab3d59ff372ac662c4257e4 due to exception
      

      Workaround

      Run a manual build

      Attachments

        Activity

          People

            mgardias Marcin Gardias
            gribeiro Gabriel Ribeiro
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: