Tutorial: Bamboo Specs YAML stored in Bitbucket Server

このページの内容

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問

This guide will show you how you can store Bamboo Specs in a Git repository on Bitbucket Server. This approach allows to automatically build and execute Bamboo Specs on every push you make to a Git repository.



はじめる前に



Step 1: Create a Git repository in Bitbucket Sever and clone it locally

  1. In Bitbucket Server, open the Projects page.
  2. [プロジェクトの作成] をクリックします。 
  3. Select  Bamboo for project name and key and click Create project.
    You see that the project has no repositories.
  4. リポジトリの作成をクリックします。
  5. Give your new repository the name tutorial, and click Create repository.

You've just created a new empty repository. Use the git clone command to create a clone on your computer. For example:

git clone http://admin@localhost:7990/scm/bamboo/tutorial.git
 

Step 2: Enable processing of Bamboo Specs in your repository

 By default Bamboo will not look for Bamboo Specs in the Git repository until your explicitly tell it to do so. Let's do it now:

  1. Go to    > Linked repositories
  2. Select your repository. 

  3. In the Bamboo Specs tab, enable Scan for Bamboo Specs.

In this tutorial we simply grant access to all projects in the Bamboo instance. You can fine-tune project access, see Enabling repository-stored Bamboo Specs how to do this.

Now, the Bamboo is ready to execute Bamboo Specs if it will be committed to the repository. Let's prepare some code.



Step 3: Create Bamboo Specs project using Maven

  1. Go to the empty Git repository you cloned in step 1:

    cd tutorial
  2. Use any of the templates we've prepared for your in Bamboo YAML Specs Reference or write YAML definition on your own with Bamboo Specs YAML format.

    It's important to save your Bamboo Specs YAML definition in the ${repo-home}/bamboo-specs/bamboo.yml or bamboo.yaml  file under the repository root.

    project:
      key: DRAGON
      plan:
        key: SLAYER
        name: Dragon Slayer Quest
    stages:
      - jobs:
          - scripts:
              - echo 'Going to slay the red dragon, watch me'
              - sleep 1
              - echo 'Nailed it'

Step 4: Create a new Project in Bamboo

  1. Open Bamboo and go to Create > Create Project.
  2. Fill in Project name.
  3. If not auto-generated, fill in the Project Key – eg: DRAGON – this will be referenced in the YAML file
  4. 保存をクリックします。



Step 4: Create a linked repository in Bamboo

  1. Open Bamboo and go to  > Linked repositories
  2. [リポジトリを追加] をクリックします。
  3. Select a Bitbucket Server / Stash repository type.
  4. Choose a name for your repository.
  5. From the Server drop-down, select your Bitbucket Server.
  6. In the Web repository section, select the Bamboo / tutorial repository from the Web repository drop-down. 
  7. Click Save repository.

Your new repository is created and you can start using it in Bamboo.



Step 5: Commit and push code changes to Bitbucket Server

  1. Add created bamboo-specs directory to VCS and push changes to the server:

    git add bamboo-specs
    git commit -m "Initial commit of Bamboo Specs"
    git push

As soon as you push your code changes to Bitbucket Server, Bamboo will get notified about a new commit available.

Bamboo will checkout your repository, process it and create plan.

Execution of Bamboo Specs will create or update configuration of plans accordingly. 



Step 6: Check if plan was created

  1. Open your Bamboo instance.
  2. From the header, select Build > All build plans
  3. Open the project and plan you've just created.

    All configuration options are disabled because entire plan configuration is now managed by Bamboo Specs from your Bitbucket repository. 

  4. Click Run plan to execute the build.

  5. Find the "Hello World!" message in the logs. 

次のステップ

 Here are some resources that can help you with writing your own Bamboo YAML Specs:

最終更新日: 2018 年 2 月 21 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.