This page describes how to configure Bamboo to use a Git source repository.

You need to have previously defined a Git capability before you can configure a Git source repository – see Defining a new version control capability.

(info) Bamboo には独自の Git 実装が組み込まれていることに注意してください。ただし、シンボリック リンク、サブモジュール、自動ブランチ検出、自動マージを使用するには、ネイティブ Git を使用する必要があります。これらは組み込みの Git ではサポートされていません。

Git は次の場所からダウンロードできます。

Bamboo OnDemand

Note that SSH authentication is not available in Bamboo OnDemand

Configuring a Git source repository

To add a new Git repository, navigate to the source repository settings for a plan or job, as described on Specifying the source repository.

  1. [リポジトリの追加] をクリックして新しいリポジトリを追加するか、既存のリポジトリ設定を編集します。
  2. [Source Repository (ソース リポジトリ)] リストから [Git] を選択します。
  3. Bamboo 内でリポジトリを識別するのに役立つ [表示名] を入力します。
  4. プランの Git ソース リポジトリ用に次の設定を指定できます。
リポジトリ URL

Git リポジトリのフル パス (例: https://bitbucket.org/atlassian/bamboo-git-plugin.git)

有効な URL の形式は次のとおりです。

  • git://host.xz[:port]/path/to/repo.git
  • ssh://[user@]host.xz[:port]/path/to/repo.git
  • [user@]host.xz[:port]/path/to/repo.git
  • http[s]://host.xz[:port]/path/to/repo.git
  • /path/to/repo.git
  • file:///path/to/repo.git 
ブランチ   作業する関連ブランチ (またはタグ) の名前を入力します。master ブランチで作業する場合は、空のままにします。
認証タイプ None (なし) – リポジトリに匿名でアクセスする場合は [None (なし)] を選択します。
Username/password (ユーザー名 / パスワード) – ユーザー名とパスワードで認証します。
SSH private key (SSH 非公開キー)SSH キーをアップロードし、対応する SSH パスフレーズを指定します。
Use shallow clones (shallow clone を使用する)

Bamboo で shallow clone を実行できるようにします (つまり、履歴は指定のリビジョン数に切り捨てられます)。これにより、最初のコード チェックアウトの速度が向上するはずですが、ビルドがリポジトリ全体の履歴に依存している場合は、このオプションを使用しないことをお勧めします。shallow clone は既定で有効になっています。

POM ファイルの場所

(上記で定義した) Git の [Repository URL (リポジトリ URL)] のルートを基準にしたプロジェクトの pom.xml ファイルのパスです。

(Maven 2 プロジェクトをインポートする場合にのみ利用可能) 

詳細オプション

サブモジュールを使用するリポジトリにサブモジュールが定義されている場合に、サブモジュールのサポートを有効にするために選択します。エージェントにネイティブの Git 機能が定義されていない場合、サブモジュールのサポートは無効になります。
コマンド タイムアウト これは、ハングした Bitbucket プロセスを停止するのに役立ちます。低速なネットワークでは、Bamboo が Git リポジトリの最初の複製を作成する時間を確保するため、既定のタイムアウトを長くすることを検討してください。
詳細なログ Git コマンドからのより詳細なログを有効にします。Bamboo で Git に関する問題が発生した場合は、このオプションを使用してください。
Enable Quiet Period (待機期間を有効にする)1 つのコミットが検出されてからビルドが開始されるまでの遅延を指定します。これによって、複数のコミットを 1 つのビルドに集約できます。
Include/Exclude Files (ファイルを含める/除外する)

Bamboo での変更の検出に使用する (または使用しない) ファイルを指定できます。"Include (含める)" オプションを設定した場合、Bamboo では変更の検出に指定のファイルのみが使用されます (既定ではすべてのファイルがチェックされます)。同様に、"Exclude (除外する)" オプションを設定した場合、Bamboo での変更の検出時に除外ファイルは無視されます。

Enter into File Pattern a regular expression to match the files that Bamboo  includes or excludes. The regex pattern must match the file path in the repository. See sub page for examples.

Exclude Changesets (チェンジセットを除外)Enter a regular expression to match the commit messages for changesets that should not start a build.
Web リポジトリ

Web ブラウザでリポジトリを表示できる場合は、リポジトリの種類を選択します。

This allows links to relevant files to be displayed in the 'Code Changes' section of a build result.

Stash - リポジトリの次の詳細を指定します。
    • Stash URL - Stash インスタンスの URL (例: https://stash.mycompany.com)。
    • Stash プロジェクト キー - Stash 内のプロジェクトのキー (例:「CONF」)。
    • リポジトリ名 - Stash 内のリポジトリの名前 (例:「conf-dev」)。

FishEye – リポジトリの URL およびその他の詳細を指定します。

    • FishEye URL - FishEye リポジトリの URL (例:「 https://atlaseye.atlassian.com/ 」)。
    • リポジトリ名 - FishEye リポジトリの名前 (例:「Bamboo」)。これは事実上、リポジトリ パスのエイリアスです。
    • リポジトリ パス - FishEye リポジトリのパス (例:「/atlassian/bamboo/」)。

リポジトリのパスを特定する方法

If you have previously run builds with changes from your repository, the easiest way of determining your repository path is to view the code changes and copy the path from the start of the path of one of the changed files, up to (but not including) the appropriate root directory. The root directories for repositories are the ones shown by FishEye when browsing a repository (e.g. trunk)). For example, if a code change listed /atlassian/bamboo/trunk/bamboo-acceptance-test/pom.xml, the path would be /atlassian/bamboo/.
If you have not previously run builds with changes from your repository, you will need to ask your FishEye administrator for the repository path indexed by FishEye.

  • ラベルなし

21 Comments

  1. Piotr Piątkowski

    What about triggers for git? Didn't find anything in documentation - table with "Build strategies" looks like copied from documentation for Subversion, not a word regarding git there.

    1. PiotrA

      Er, what do you mean by 'triggers for git'? What kind of information you need which the above documentation lacks?

      1. Piotr Piątkowski

        I need information how to configure git, to automatically trigger bamboo build after each push. Second option in "build strategies" table - there's a link to this page: http://confluence.atlassian.com/display/BAMBOO/Repository+Triggers+the+Build+when+Changes+are+Committed, but nothing about git can be found there.

        1. PiotrA

          I'd say you need to:

          • add post-receive script to your git repository. For example my .git/hooks/post-receive looks like:
            #!/bin/sh
            wget --bind-address=127.0.0.1 http://localhost:8085/bamboo/updateAndBuild.action?buildKey=HOOK-HOOK -O /dev/null
            
            (where http://localhost:8085/bamboo is my Bamboo basedir, and HOOK-HOOK is the project-plan key for the plan using Git Repository)
          • you might need to tweak Trigger IP Address (Bamboo->Plan->Repository Configuration page). For example I had to change it to:
            127.0.0.1
            

          And that should do the trick. Does it help?

          1. Piotr Piątkowski

            Yes, Piotr, I see that you added info to the page about Git configuration too, and that's exactly what I was asking for - thank you.

          2. David Kowis

            Does this still work since the remote API is gone, and now we've got a REST api?

            I couldn't find stuff in the REST API about triggering a build.

            Thanks, David

            1. PiotrA

              I believe this still work - the above mechanism is not depending on "remote API" nor on the REST api. For the full reference - one can use REST "queue" endpoint to trigger the builds manually, but I don't see a reason why one would favourite REST instead of the plain  "updateAndBuild.action".

              Why do you ask? Any particular problem you're experiencing? Maybe we can help somehow?

              1. David Kowis

                Yeah I'm having trouble with it, it doesn't seem to be triggering my Plan. I've got a support request open: https://support.atlassian.com/ja/browse/BSP-10330

                Thanks (smile)

                1. PiotrA

                  Just a question: do you want to trigger the build and run it no-matter-if-there-are-any-new-changes-in-the-repo, or do you want to trigger only the change detection on the repository?

                  If you need to trigger the build (I assume that is the case, am I right?), then the following REST endpoint should help in your situation: https://docs.atlassian.com/bamboo/REST/4.0/#idp263696 - "POST" on the "/queue" resource. Can you make it on your own with that information how to call that endpoint, or do you need further help?

                  1. David Kowis

                    I think that solves my problem. Change detection is fine, since it should only be pushed via git on a push, but I don't mind if it runs "unnecessarily"

                    I executed this:

                    POST server:port/rest/api/latest/queue/PLAN-KEY 

                    I get a 401 unauthorized, I guess it requires me to set up a username and password explicitly for the automated builds? That's a bit trickier to make work with github. 

                    1. PiotrA

                      Hm... In that case the "updateAndBuild.action" should be preferable. I do wonder why does it not work on your machine. But I think diagnosing this won't be easy and it is good idea that you've raised that BSP-10330 - I've added myself to its watchers. I hope that with a help from Support Engineer you'll get to the root of the problem soon.

                      I'll pass here, as I reckon the issue is too big to be discussed via Bamboo Documentation comments, and I am unable to help you further right now. Is that OK to you?

                      good night! (smile)

                      1. David Kowis

                        Totally OK with me, thanks for your help.

  2. Daniel Nugent

    Is there a specific version of git that shallow clones have been tested with? I've noticed that on some repos (very small ones, I think, 556K with the one I consistently reproduce the problem with), enabling shallow clones causes the clone command to hang indefinitely. Switching to full clones works fine.

    I am using git 1.7.10.1 with my build agent.

  3. Anonymous

    Is there any support for having the output of 'git describe' passed to a Bamboo environment variable during a build?

  4. Anonymous

    Committing to a branch still causes master to compile and my branch does not get compiled when using manual branches.   Is this a known issue with bamboo integration or have I neglected something in my branch trigger. I do specify master for master.  Using GitHub services hooks which trigger on commit to bamboo.  It looks like I can specify the main project-plan which is how I trigger the build.  

    1. PiotrA

      I think you should use "polling" strategy in Bamboo instead of relying on GitHub services to "ping" the Bamboo. I'm guessing GitHub services aren't aware of plan-branches created in Bamboo, so they always trigger the master-plan...

  5. Thomas Verhülsdonk

    I just wanted to point out that the SSH-authentication for a git repository won't work if the private-key is in putty format.
    When I converted it to the openssh format, it worked fine. 

  6. Malte Hübner

    Checking out a tag does not seem to work. I have to checkout the tag manually with a script task.

    The documentation shoult mention this:

    Type the name of the relevant branch (or tag) you want to work on. Leave empty to work on the master branch.

     

  7. Andrew Morin

    Not critical but is there any way to clone or copy a shared repository?

     

    Dang it I have done the captcha 15+ times...what the heck????

  8. Rick Steckles

    Is it possible to store an SSH public key in Bamboo, rather than having to upload it via a webform for each new plan? Ideally we want to create a 'bamboo' user in Stash so we don't have to use a random individual's authentication details in a build plan. However, we'd still have to manually upload an SSH key. Does Bamboo provide a key store?

    1. ArmenA

      Hi Rick,

      I am sorry for the confusion; Bamboo 5.2 has this feature as it's mentioned here - https://answers.atlassian.com/questions/231064/store-stash-ssh-key-on-the-bamboo-server?page=1#231271. You need navigate to the Administration -> Shared credentials page.

      Armen