Tutorial: Bamboo Specs YAML stored in Bitbucket Server

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

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



Before you begin



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

  1. In Bitbucket Data Center, open the Projects page.
  2. Click Create project
  3. Select  Bamboo for project name and key and click Create project.
    You see that the project has no repositories.
  4. Click Create repository.
  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: Create Bamboo Specs YAML config 

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

    cd tutorial
    mkdir bamboo-specs
    cd bamboo-specs
    echo > bamboo.yml
  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.

    ---
    version: 2
    plan:
      project-key: MARS
      key: ROCKET
      name: Build the rocket
    stages:
      - Build hull:
        - Build
    
    Build:
      tasks:
        - script:
          - echo 'Hello World!'
  3. 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

Step 3: Create a new Project in Bamboo

  1. Open Bamboo and go to Create > Create Project.
  2. Fill in Project name, e.g. Mars
  3. If not auto-generated, fill in the Project Key – eg: MARS – this will be referenced in the YAML file.
  4. Click Save.

Step 4: 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  Specs > Set up Specs repository
  2. Select your project Mars

  3. Select Link new repository
  4. Select a Bitbucket Data Center repository type.
  5. Choose a name for your repository.
  6. From the Server menu, select your Bitbucket Data Center.
  7. Select the Bamboo / tutorial repository from the Repository drop-down. 
  8. Click Confirm.

Your new repository is created and you can start using it in Bamboo. Bamboo will checkout your repository, process it and create plan.

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

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



Step 5: Check if plan was created

  1. In Bamboo from the header, select Build > All build plans
  2. 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. 

  3. Click Run plan to execute the build.

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


Regardless whether your Bamboo Specs were processed successfully or not, you'll receive an email with status of you your Bamboo Specs execution.

Next steps

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

Last modified on Jan 19, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.