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

JGit cannot follow 301 redirects when performing Git commands

    XMLWordPrintable

Details

    • Bug
    • Resolution: Answered
    • Low
    • None
    • None
    • Repository (Git)
    • None

    Description

      Summary

      When using HTTP for Git repositories and no native git binary is installed, Bamboo will use a Java Git implementation (JGit) to perform git commands. If the address for the repository results in a 301 redirect to another location, the git command will fail with an exception.

      Steps to Reproduce

      1. Remove any native git capabilities
      2. Create a plan and add a Git repository with a HTTP URL that performs a 301 redirect to an actual repository
      3. Add a source code checkout task
      4. Run the plan

      Expected Results

      Git commands succeed

      Actual Results

      The below exception is thrown:

      error	18-Oct-2017 15:58:03	java.lang.RuntimeException: com.atlassian.bamboo.repository.RepositoryException: Cannot fetch branch from 'https://bitbucket.server.com/scm/proj/repo.git' to source directory 'builddir'. https://bitbucket.server.com/scm/proj/repo.git: 301 Moved Permanently
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.executor.RetryingTaskExecutor.rerun(RetryingTaskExecutor.java:141)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.executor.RetryingTaskExecutor.runTask(RetryingTaskExecutor.java:99)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.executor.RetryingTaskExecutor.retry(RetryingTaskExecutor.java:207)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.executor.RetryingTaskExecutor.retry(RetryingTaskExecutor.java:188)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.plugins.vcs.task.VcsCheckoutTask.execute(VcsCheckoutTask.java:121)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.task.TaskExecutorImpl.lambda$executeTasks$3(TaskExecutorImpl.java:284)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.task.TaskExecutorImpl.executeTaskWithPrePostActions(TaskExecutorImpl.java:223)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.task.TaskExecutorImpl.executeTasks(TaskExecutorImpl.java:284)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.task.TaskExecutorImpl.executePreparationTasks(TaskExecutorImpl.java:91)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.build.pipeline.tasks.PrepareBuildTask.call(PrepareBuildTask.java:74)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent.build(DefaultBuildAgent.java:185)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:120)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl$1.call(BuildAgentControllerImpl.java:113)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.variable.CustomVariableContextImpl.withVariableSubstitutor(CustomVariableContextImpl.java:185)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.v2.build.agent.BuildAgentControllerImpl.waitAndPerformBuild(BuildAgentControllerImpl.java:113)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.v2.build.agent.DefaultBuildAgent$1.run(DefaultBuildAgent.java:126)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.utils.BambooRunnables$1.run(BambooRunnables.java:47)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.security.ImpersonationHelper.runWith(ImpersonationHelper.java:26)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.security.ImpersonationHelper.runWithSystemAuthority(ImpersonationHelper.java:17)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.security.ImpersonationHelper$1.run(ImpersonationHelper.java:41)
      error	18-Oct-2017 15:58:03		at java.lang.Thread.run(Unknown Source)
      error	18-Oct-2017 15:58:03	Caused by: com.atlassian.bamboo.repository.RepositoryException: Cannot fetch branch from 'https://bitbucket.server.com/scm/proj/repo.git' to source directory 'builddir'. https://bitbucket.server.com/scm/proj/repo.git: 301 Moved Permanently
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.plugins.git.JGitOperationHelper$4.doWithTransport(JGitOperationHelper.java:311)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.plugins.git.JGitOperationHelper$4.doWithTransport(JGitOperationHelper.java:299)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.plugins.git.JGitOperationHelper.withTransport(JGitOperationHelper.java:861)
      error	18-Oct-2017 15:58:03		at com.atlassian.bamboo.plugins.git.JGitOperationHelper.fetchInternal(JGitOperationHelper.java:299)
      

      Resolution

      Option 1:

      • Install a native git binary on the agent (Bamboo Server for local agents) responsible for performing the build and ensure a capability has been added for it.

      Option 2:

      • Change the repository URL to the direct address which does not have a proxy server performing a 301 redirect

      Attachments

        Activity

          People

            Unassigned Unassigned
            jowen@atlassian.com Jeremy Owen
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: