Public | Automated Build

Last pushed: 6 months ago
Short Description
Concourse Resource for managing Bitbucket Pull Requests
Full Description

A Concourse resource to interact with the build status API of Atlassian BitBucket.

This repo is tied to the associated Docker image on Docker Hub, built from the master branch.

Resource Configuration

These items go in the source fields of the resource type. Bold items are required:

  • repo - repository name to track
  • key - OAuth key for Consumer
  • secret - OAuth Secret for Consumer
  • team - Team name repository belongs to
  • url - bitbucket cloud api path (example: https://api.bitbucket.org) Currently only supported
  • version - bitbucket API Version (example: 2.0) Currently only supported
  • concourse_url - concourse url for setting build link in bitbucket (example: http://ci.example.com)

Behavior

check

Checks for a Pull request with a head commit in an untested state.

in

Retrieves a copy of the tracking branch used for checking out the branch and testing.

out

Update the status of a commit.

Parameters:

  • commit - File containing commit SHA to be updated.
  • state - the state of the status. Must be one of success or failed.

Example

A typical use case is to watch for Pull Requests on a Repository, Run Tests and update the status of a commit.


resource_types:
  - name: pull-request
    type: docker-image
    source:
      repository: thebeefcake/concourse-resource-bitbucket

resources:
  - name: repo-pullrequest
    type: pull-request
    source:
      repo: {{repo-name}}
      secret: {{bitbucket-secret}}
      key: {{bitbucket-key}}
      team: {{team-name}}
      url: https://api.bitbucket.org
      version: "2.0"
      concourse_url: http://ci.example.com

jobs:
  - name: run-tests
    plan:
    - get: repo-pullrequest
      trigger: true
    - task: test
      config:
        platform: linux
        image_resource:
          type: docker-image
          source: {repository: alpine}
        inputs:
          - name: repo-pullrequest
        outputs:
          - name: pr
        run:
          path: sh
          args:
          - -exc
          - |
            apk add --update --no-cache git
            version=$(cat repo-pullrequest/version)
            commit=$(cat repo-pullrequest/commit)
            branch=$(cat repo-pullrequest/branch)
            cd repo-pullrequest && git checkout $branch
            # Run tests
            echo $version | tee tags/version
            echo $commit | tee tags/commit
      on_failure:
        put: repo-pullrequest
        params:
          state: failed
          commit: pr/commit
      on_success:
        put: repo-pullrequest
        params:
          state: success
          commit: pr/commit

Installation

This resource is not included with the standard Concourse release. Use one of the following methods to make this resource available to your pipelines.

Deployment-wide

To install on all Concourse workers, update your deployment manifest properties to include a new groundcrew.resource_types entry...

properties:
  groundcrew:
    additional_resource_types:
      - image: "docker:///thebeefcake/concourse-resource-bitbucket#master"
        type: "pull-request"                   

Pipeline-specific

To use on a single pipeline, update your pipeline to include a new resource_types entry...

resource_types:
  - name: "pull-request"
    type: "docker-image"
    source:
      repository: "thebeefcake/concourse-resource-bitbucket"
      tag: "master"

References

License

Apache License v2.0

Docker Pull Command
Owner
thebeefcake

Comments (0)