Tutorial: Bamboo Java Specs 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.
Make sure you have the required software installed.
- Set up an application link between Bamboo and Bitbucket Server. See Integrating Bamboo with Bitbucket Server.
- If you don't know Bamboo Specs yet, make sure to read our introductory tutorial: .Tutorial: Create a simple plan with Bamboo Specs v6.2.
Step 1: Create a Git repository in Bitbucket Sever and clone it locally
- In Bitbucket Server, open the Projects page.
- Click the Create project.
Bamboofor project name and key and click Create project.
You see that the project has no repositories.
- Click Create repository.
- Give your new repository the name
tutorialand 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 a linked repository in Bamboo
- Open Bamboo and go to > Linked repositories.
- Click Add repository.
- Select a Bitbucket Server / Stash repository type.
- Choose a name for your repository.
- From the Server drop-down, select your Bitbucket Server.
- In the Web repository section, select the
Bamboo / tutorialrepository from the Web repository drop-down.
- Click Save repository.
Your new repository is created and you can start using it in Bamboo.
Step 3: 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:
- Go to > Linked repositories.
Select your repository.
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 4: Create Bamboo Specs project using Maven
Go to the empty Git repository you cloned in step 1:
Use the Maven archetype to create a project template. For the purpose of this tutorial, type:
It's important to create Bamboo Specs in the
bamboo-specsdirectory, under the repository root.
mvn archetype:generate -B \ -DarchetypeGroupId=com.atlassian.bamboo -DarchetypeArtifactId=bamboo-specs-archetype \ -DarchetypeVersion=6.2.1 \ -DgroupId=com.my.company -DartifactId=bamboo-specs \ -Dversion=1.0.0-SNAPSHOT -Dpackage=com.my.company
Your project is created. You can open it in IDE, such as Eclipse or IDEA if you want to see how the project looks like. Also see the introductory .Tutorial: Create a simple plan with Bamboo Specs v6.2 to get familiar with the code structure.
Step 5: Commit and push code changes to Bitbucket Server
bamboo-specsdirectory 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 project, compile it and execute Bamboo Specs in a sandbox environment.
Execution of Bamboo Specs will create or update configuration of plans or deployment projects accordingly.
Step 6: Check if plan was created
- Open your Bamboo instance.
- From the header, select Build > All build plans.
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.
Click Run plan to execute the build.
- Find the "Hello World!" message in the logs.
Here are some resources that can help you with writing your own Bamboo Specs: