[Bamboo Knowledge Base]
This page describes how to use Bamboo to get rapid feedback on your PHP project. The example on this page builds a Bamboo plan where a developer commits code and Bamboo responds by:
On this page:
This introduction assumes you are using Bamboo Server installed on your local network. You need to make sure you or your company administrator have properly installed and configured Bamboo for running plans.
You will also need to install:
In order to get full functionality from Bamboo and PHP, you will need to install the PHP base code framework. If you are using Ubuntu, then use the following command to install PHP.
$ sudo apt-get install php5-cli
See also:
PHPUnit.de provides an excellent PHP archive resource called PHAR.
$ wget https://phar.phpunit.de/phpunit.phar // download the PHPUnit packages $ chmod +x phpunit.phar // make PHPUnit executable $ mv phpunit.phar /usr/local/bin/phpunit // copy PHPUnit into your path $ phpunit --version // double check it's installed completely
If you prefer, you may use Composer or PEAR to download and install PHPUnit along with its dependencies, however these approaches are beyond the scope of this introduction.
A Bamboo plan defines the details of your continuous integration workflow. You use a plan to identify the source code repository, specify the tasks to run in your build, and when to trigger a build. Each plan belongs to a project. You can add a plan to an existing project or create a new project. In this example, you create both a new project and a new plan in that project.
Every plan belongs to a project. We don't have a project yet, so choose Project > New Project, and enter details for both the project and plan.
Project | New Project |
---|---|
Project Name | TestProject |
Project Key | TP |
Bamboo needs to know the Plan name, Plan key and a brief description of what the plan is for. See Configuring plans for more details.
Plan name | Tutorials |
---|---|
Plan key | TUT |
Description | Build Atlassian tutorials |
Bamboo needs to know where the source code repository is located, and needs access to the repo so that it can check out the code when it runs a build. See Linking to source code repositories for more details.
Source Repository | Bitbucket |
---|---|
Username | Your Bitbucket username |
Password | Your Bitbucket password |
Repository | atlassian_tutorial/hellworld (git) |
Branch | master |
Use shallow clones | Set this checkbox |
We can choose how Bamboo gets triggered to run the plan build:
Trigger type | Repository triggers the build when changes are comitted |
---|---|
Trigger IP | Optionally add an IP address for your repository |
See Triggering builds for more details.
Each plan needs to have at least one task specified. Tasks do the real work of the plan.
A newly created plan has a default Source Code Checkout task that gets the source code from the source repository specified earlier.
See Checking out code for details.
We also want to compile the code, and run the unit and integration tests. We'll add a builder task to the Bamboo plan to do that. You will need to have installed PHP and Phing in order to use the PHP build tasks.
Click Add Task, then Builder and choose the Phing task for your project:
Note that:
Unit testing for PHP is completed using the PHPUnit testing framework. This is a port of the popular Java JUnit testing framework to PHP. PHPUnit provides also produces test results in the JUnit XML format required by Bamboo.
You will need to add a server executable capability to run PHPUnit:
Click Add capability and complete the configuration using the following:
Capability type | Executable |
---|---|
Type | PHPUnit |
Executable label | PHPUnit x.x |
Path | Path to the PHPUnit executable e.g. /usr/bin/phpunit-x.x |
Now you can create a PHPUnit testing task:
Your tests will be run when the builder task compiles the code. Each of the builder tasks above has a section to tell Bamboo to expect test results and where to look for them. You can specify a custom results location if your project directory doesn't use the conventional structure.
See Jobs and tasks for details.
Enable the plan, and click Create.
You should see the plan run. The 'Plan Summary' tab will report whether the build succeeded or not.
Tests in the appropriate directory in the source code repository will be run automatically as part of the build, and the test results will be displayed in Bamboo.
Now, whenever you commit a change to the repository, Bamboo will build your source code and report on your test results.
Bamboo displays a summary of the results of the build on the dashboard.
You can get further information about the build in the following ways:
See Getting feedback for details.