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

Push back to Git repository - Preserve origin in repositories

    XMLWordPrintable

Details

    • 11
    • 11
    • Our product teams collect and evaluate feedback from a number of different sources. To learn more about how we use customer feedback in the planning process, check out our new feature policy.

    Description

      Having a repository Git in Stash, Bitbucket or any other location and adds it to Bamboo under "Bamboo administration >> Build resources >> Linked repositories" or under "Plan configuration >> Repositories" tab does not enables Bamboo to push back to a repository.

      Once you create a "Source Code Checkout" task and run your build, Bamboo will checkout from your repository under the "<bamboo-home>/xml-data/build-dir/<project-plan-key>" directory by default.

      Bamboo Server

      In Bamboo Server, running the following command under the directory "<bamboo-home>/xml-data/build-dir/<project-plan-key>/.git" you will:

      # command:
      git config -l
      
      # response (sample)
      11-Sep-2014 10:41:03	user.name=<USER NAME>
      11-Sep-2014 10:41:03	user.email=<USER EMAIL>
      11-Sep-2014 10:41:03	core.editor=<EDITOR>
      11-Sep-2014 10:41:03	core.excludesfile=/Users/<USER>/.gitignore_global
      11-Sep-2014 10:41:03	difftool.sourcetree.cmd=opendiff "$LOCAL" "$REMOTE"
      11-Sep-2014 10:41:03	difftool.sourcetree.path=
      11-Sep-2014 10:41:03	mergetool.sourcetree.cmd=/Applications/SourceTree.app/Contents/Resources/opendiff-w.sh "$LOCAL" "$REMOTE" -ancestor "$BASE" -merge "$MERGED"
      11-Sep-2014 10:41:03	mergetool.sourcetree.trustexitcode=true
      11-Sep-2014 10:41:03	core.repositoryformatversion=0
      11-Sep-2014 10:41:03	core.filemode=true
      11-Sep-2014 10:41:03	core.bare=false
      11-Sep-2014 10:41:03	core.logallrefupdates=true
      11-Sep-2014 10:41:03	core.ignorecase=true
      11-Sep-2014 10:41:03	core.precomposeunicode=true
      11-Sep-2014 10:41:03	remote.origin.url=file:///<BAMBOO_HOME>/xml-data/build-dir/_git-repositories-cache/93be3...
      11-Sep-2014 10:41:03	remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
      11-Sep-2014 10:41:03	branch.master.remote=origin
      11-Sep-2014 10:41:03	branch.master.merge=refs/heads/master
      

      Please, notice the entry (11-Sep-2014 10:41:03 remote.origin.url) is pointing to a cache file that Bamboo creates once a repository is linked.

      By going to "Bamboo administration >> Build resources >> Repository settings" you will find all cached repositories Git under the "Git" section.

      Bamboo Cloud

      In Bamboo Cloud, it is more likely the "remote.origin.url" will be pointing to "file://nothing" as per following:

      11-Sep-2014 10:43:12	remote.origin.url=file://nothing
      

      In either Bamboo Server or Bamboo Cloud by running the following command in a Script task you will find something like:

      # command
      git remote -v
      
      # response (sample)
      11-Sep-2014 10:45:32	origin        file:///<BAMBOO_HOME>/xml-data/build-dir/_git-repositories-cache/93be3c87266225a94f8f1c1929ecb2b0e85c989a (fetch)
      11-Sep-2014 10:45:32	origin        file:///<BAMBOO_HOME>/xml-data/build-dir/_git-repositories-cache/93be3c87266225a94f8f1c1929ecb2b0e85c989a (push)
      

      Depending on the Git repository you are working with, you would be able to push back to your repository by updating the remote.origin.url to point to your repository instead to a cache file.

      In order to do it so, you can create a "Script" task in your Bamboo plan and add the following:

      git remote remove origin
      git remote add origin ssh://git@<stash-baseURL>:7999/<project-key>/<repository>.git
      ...
      

      Instead of having to ask clients to update the remote origin to be "able to push back to a Git repository" it would be beneficial to have an option where you could choose if:

      1. you want to work with a cache file or;
      2. you want to preserve origin

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              rsperafico Rafael Sperafico (Inactive)
              Votes:
              49 Vote for this issue
              Watchers:
              50 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: