GithubHelp home page GithubHelp logo

isabella232 / pullrequest-resource Goto Github PK

View Code? Open in Web Editor NEW

This project forked from periscopedata/pullrequest-resource

0.0 0.0 0.0 161 KB

Provides a pull request resource for concourse CI.

License: MIT License

Ruby 94.83% Shell 5.17%

pullrequest-resource's Introduction

Github Pull Request Resource

Tracks pull requests made to a particular github repo. In the spirit of Travis CI, a status of pending, success, or failure will be set on the pull request, which must be explicitly defined in your pipeline.

Deploying to Concourse

You can use the docker image by defining the resource type in your pipeline YAML.

For example:

resource_types:
- name: pull-request
  type: docker-image
  source:
    repository: jtarchie/pr

Source Configuration

  • repo: Required. The repo name on github. Example: jtarchie/pullrequest-resource

  • access_token: Required. An access token with repo:status access is required for public repos. An access tocken with repo access is required for private repos.

  • uri: Optional. The URI to the github repo. By default, it assumes https://github.com/`repo`.

  • base: Optional. When set, will only pull PRs made against a specific branch. The default behaviour is any branch.

  • base_url: Optional The base URL for the Concourse deployment, used for linking to builds. On newer versions of Concourse ( >= v0.71.0) , the resource will automatically sets the URL.

  • private_key: Optional. Private key to use when pulling/pushing. Example:

    private_key: |
      -----BEGIN RSA PRIVATE KEY-----
      MIIEowIBAAKCAQEAtCS10/f7W7lkQaSgD/mVeaSOvSF9ql4hf/zfMwfVGgHWjj+W
      <Lots more text>
      DWiJL+OFeg9kawcUL6hQ8JeXPhlImG6RTUffma9+iGQyyBMCGd1l
      -----END RSA PRIVATE KEY-----
    
  • api_endpoint: Optional. If the repository is located on a GitHub Enterprise instance you need to specify the base api endpoint (e.g. "https://<hostname>/api/v3/").

  • disable_forks: Optional. If set to true, it will filter out pull requests that were created via users that forked from your repo.

  • label: Optional. If set to a string it will only return pull requests that have been marked with that specific label. It is case insensitive.

  • username: Optional. Username for HTTP(S) auth when pulling/pushing. This is needed when only HTTP/HTTPS protocol for git is available (which does not support private key auth) and auth is required.

  • password: Optional. Password for HTTP(S) auth when pulling/pushing.

  • paths: Optional. If specified (as a list of glob patterns), only changes to the specified files will yield new versions from check.

  • ignore_paths: Optional. The inverse of paths; changes to the specified files are ignored.

  • skip_ssl_verification: Optional. Skips git ssl verification by exporting GIT_SSL_NO_VERIFY=true.

  • git_config: Optional. If specified as (list of pairs name and value) it will configure git global options, setting each name with each value.

    This can be useful to set options like credential.helper or similar.

    See the git-config(1) manual page for more information and documentation of existing git options.

Behavior

check: Check for new pull requests

Concourse resources always iterate over the latest version. This maps well to semver and git, but not with pull requests. To find the latests pull requests, check queries for all PRs, selects only PRs without concourse-ci status messages, and then only returns the oldest one from list.

To ensure that check can iterate over all PRs, you must explicitly define an out for the PR.

in: Clone the repository, at the given pull request ref

Clones the repository to the destination, and locks it down to a given ref. It is important to specify version: every, otherwise you will only ever get the latest PR.

Submodules are initialized and updated recursively, there is no option to to disable that, currently.

There is git config information set on the repo about the PR, which can be consumed within your tasks.

For example:

git config --get pullrequest.url        # returns the URL to the pull request
git config --get pullrequest.branch     # returns the branch name used for the pull request
git config --get pullrequest.id         # returns the ID number of the PR
git config --get pullrequest.basebranch # returns the base branch used for the pull request

Parameters

  • git.depth: Optional. If a positive integer is given, shallow clone the repository using the --depth option.

  • git.submodules: Optional. If none, submodules will not be fetched. If specified as a list of paths, only the given paths will be fetched. If not specified, or if all is explicitly specified, all submodules are fetched.

  • fetch_merge: Optional. If set to true, it will fetch what the result of PR would be otherwise it will fetch the origin branch. Defaults to false.

out: Update the status of a pull request

Set the status message for concourse-ci context on specified pull request.

Parameters

  • path: Required. The path of the repository to reference the pull request.

  • status: Required. The status of success, failure, error, or pending.

    • on_success and on_failure triggers may be useful for you when you wanted to reflect build result to the PR (see the example below).
  • context: Optional. The context on the specified pull request (defaults to status). Any context will be prepended with concourse-ci, so a context of unit-tests will appear as concourse-ci/unit-tests on Github.

  • comment: Optional. The file path of the comment message. Comment owner is same with the owner of access_token.

** EXPERIMENTAL **

These are experimental features according to Github documentation.

  • merge.method: Optional. Use this to merge the PR into the target branch of the PR. There are three available merge methods -- merge, squash, or rebase. Please this doc for more information.

  • merge.commit_msg: Optional. Used with merge to set the commit message for the merge. Specify a file path to the merge commit message.

Example pipeline

Please see this repo's pipeline for a perfect example.

Tests

Requires ruby to be installed.

gem install bundler
bundle install
bundle exec rspec

pullrequest-resource's People

Contributors

bcutler-work avatar camelpunch avatar ckaznocha avatar databus23 avatar everpeace avatar fmy avatar gl4di4torrr avatar henrytk avatar jmcarp avatar joefitzgerald avatar jtarchie avatar trizko 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.