medicorenl/bamboo-api-bundle

There is no license information available for the latest version (dev-master) of this package.

Bamboo REST API integration in Symfony2

Installs: 69

Dependents: 0

Suggesters: 0

Security: 0

Stars: 3

Watchers: 6

Forks: 1

Open Issues: 0

Type:symfony-bundle

dev-master 2013-09-11 10:35 UTC

This package is not auto-updated.

Last update: 2024-04-22 11:54:55 UTC


README

Master: Build Status

A Symfony2 bundle that integrates the Bamboo REST API into native Symfony2 services.

Installation

  1. Install Composer.

    # Install Composer
    curl -sS https://getcomposer.org/installer | php
  2. Add this bundle to the composer.json file of your project.

    # Add BambooApiBundle as a dependency
    php composer.phar require medicorenl/jira-api-bundle dev-master
  3. After installing, you need to require Composer's autloader in the bootstrap of your project.

    // app/autoload.php
    $loader = require __DIR__ . '/../vendor/autoload.php';
  4. Add the bundle to your application kernel.

    // app/AppKernel.php
    public function registerBundles()
    {
        return array(
            // ...
            new BambooApiBundle\BambooApiBundle(),
            // ...
        );
    }
  5. Configure the bundle by adding parameters to the config.yml file:

    # app/config/config.yml
        bamboo_api.url:         "http://bamboo.your-organisation.com/rest/api/latest/"
        bamboo_api.credentials: "username:password"

Usage

This bundle contains a number of services, to access them through the service container:

// Get the BambooApiBundle\Service\BuildService
$buildService = $this->get('bamboo_api.build');
$buildService->getLatestResults($options);

// Get the BambooApiBundle\Service\ProjectService
$planService = $this->get('bamboo_api.project');
$planService->getAllPlans($options);

You can also add them to the service container of your own bundle:

<!-- src/Project/Bundle/Resources/config/services.xml -->
<?xml version="1.0" encoding="UTF-8"?>
<container xmlns="http://symfony.com/schema/dic/services"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services$
    <services>
        <service id="myproject.myservice" class="MyProject\MyBundle\Services\MyService.php" public="true">
            <argument type="service" id="bamboo_api.build" />
            <argument type="service" id="bamboo_api.plan" />
        </service>
    </services>
</container>

You can then use them in your own services

<?php

namespace Project\Bundle\Services;

use BambooApiBundle\Service\BuildService;
use BambooApiBundle\Service\PlanService;

/**
 * Service class for my bundle.
 */
class MyService
{
    /**
     * @var \BambooApiBundle\Service\BuildService
     */
    private $buildService;

    /**
     * @var \BambooApiBundle\Service\PlanService
     */
    private $planService;

    /**
     * Constructor.
     *
     * @param \BambooApiBundle\Service\BuildService $buildService
     * @param \BambooApiBundle\Service\PlanService  $planService
     */
    public function __construct(
        BuildService $buildService,
        PlanService  $planService,
    ) {
        $this->buildService = $buildService;
        $this->planService  = $planService;
    }
}

Unit testing

BambooApiBundle uses PHP Unit for unit testing.

  1. Download PHP Unit.

    # Download PHP Unit
    wget http://pear.phpunit.de/get/phpunit.phar
    chmod +x phpunit.phar
  2. Make sure all dependencies are installed through Composer.

    # Install dependencies
    php composer.phar install
  3. Run the unit tests.

    # Run unit tests
    php phpunit.phar