zarplata / concourse-git-bitbucket-pr-resource

:rocket: Concourse CI resource for tracking git branches of Bitbucket pull-requests
MIT License
34 stars 43 forks source link
bitbucket concourse concourse-ci concourse-ci-resource concourse-resource

concourse-git-bitbucket-pr-resource

Tracks changes for all git branches for pull requests.

This resource is meant to be used with version: every.

Inspirited by git-branch-heads-resourse

Installation

Add the following resource_types entry to your pipeline:

---
resource_types:
- name: git-bitbucket-pr
  type: docker-image
  source:
    repository: zarplata/concourse-git-bitbucket-pr-resource

Source Configuration

Example

resources:
- name: my-repo-with-pull-requests
  type: git-bitbucket-pr
  source:
    base_url: http://bitbucket.local
    username: some-username
    password: some-password
    project: zarplata
    repository: concourse-git-bitbucket-pr-resource
    git:
      uri: https://github.com/zarplata/concourse-git-bitbucket-pr-resource
      private_key: {{git-repo-key}}

jobs:
  - name: my build
    plan:    
      - get: my-repo-with-pull-requests
        trigger: true
        version: every
      - task: unit test
          ...
          inputs:          
            - name: my-repo-with-pull-requests
          run:
          ...
        on_failure:
          put: my-repo-with-pull-requests
          params:
            action: change-build-status
            state: FAILED
            name: "unit test"
            url: "http://acme.com/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME"
        on_success:
          put: my-repo-with-pull-requests
          params:
            action: change-build-status
            state: SUCCESSFUL
            name: "unit test"
            url: "http://acme.com/teams/$BUILD_TEAM_NAME/pipelines/$BUILD_PIPELINE_NAME/jobs/$BUILD_JOB_NAME/builds/$BUILD_NAME"

Behavior

check: Check for changes to all pull requests.

The current open pull requests fetched from Bitbucket server for given project and repository. Update time are compared to the last fetched pull request.

If any pull request are new or updated or removed, a new version is emitted.

in: Fetch the commit that changed the pull request.

This resource delegates entirely to the in of the original Git resource, by passing through source.git to source of the original git-resource, then specifying source.branch as the branch that changed, and version.ref as the commit on the branch.

Parameters

All params, except the ones listed below, will be passed through to params of the original git-resource.

out: Update the PR.

Behavior depends on the value of parameter action, where is the values are:

Troubleshooting