GithubHelp home page GithubHelp logo

concourse-bitbucket-resource's Introduction

This repo is inspired by pickledrick/concourse-bitbucket-pullrequest-resource

A Concourse resource to trigger on commits to a specific branch on a private Bitbucket repository as well as interact with the build status API of Atlassian BitBucket.

This repo is tied to the associated Docker image on quay.io, 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
  • branch - the branch to check and get
  • secret - OAuth Secret for Consumer
  • team - Team name repository belongs to
  • concourse_url - concourse url for setting build link in bitbucket (example: http://ci.example.com)

Behavior

check

Checks for commits on the specified repository and branch. If no version available (first run), will return the HEAD commit. If there is a current version available, will then return the ones newer than the current one.

in

Retrieves a copy of the commit and sets its build state to INPROGRESS.

out

Updates 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, failed or inprogress. By using inprogress we can use this resource for updating the status of builds but if you use this resource for get, perform task and then put, then the inprogress updating will be done for you by the in script.

Reading logs

The logs can be found by running fly -t <target-name> intercept -c <pipeline-name>/<resource-name> and then looking for check_logfile.txt, in_logfile.txt and out_logfile.txt in the ~/root/ directory.

Example

This resource can be added as a custom resource type, then defined as a resource and then used as follows

resource_types:
- name: concourse-bitbucket-resource
  type: docker-image
  source:
    repository: quay.io/pontusarfwedson/concourse-bitbucket-resource

resources:
  - name: ((repo))-test-pr-branch
    type: concourse-bitbucket-resource
    source:
      repo: ((repo))
      branch: "TEST_PR"
      secret: ((bitbucket_secret))
      key: ((bitbucket_key))
      team: teamname
      concourse_url: https://concourse-url.com



jobs:
- name: test-((repo))-poar-bitbucket-resource
  plan:
  - get: ((repo))-test-pr-branch
    trigger: true
  - task: test-((repo))-TEST-PR-branch
    privileged: true
    file: ((repo))-test-pr-branch/build/tasks/task.yaml
    input_mapping: {repo: ((repo))-test-pr-branch} 
    params:
      REPO: ((repo))
      BRANCH: TEST_PR
    on_success:
      put: ((repo))-test-pr-branch
      params:
        commit: ((repo))-test-pr-branch/commit
        state: success
    on_failure:
      put: ((repo))-test-pr-branch
      params:
        commit: ((repo))-test-pr-branch/commit
        state: failed

References

License

Apache License v2.0

concourse-bitbucket-resource's People

Stargazers

 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.