class EnvPullRequest::Base
Pull request information object from environment variables
Attributes
pull_request_id[R]
Public Class Methods
new() { ||| fetch_pull_request_id| ... }
click to toggle source
Build pull request information object from environment variables
@overload initialize
@example without user defined block env_pull = EnvPullRequest::Base.new @return [Base] pull request information object
@overload initialize(&block)
@example with user defined block env_pull = EnvPullRequest::Base.new do if NaturalNumberString .positive_integer_string? ENV['PULL_REQUEST_ID'] ENV['PULL_REQUEST_ID'].to_i end end @yield user defined block @return [Base] pull request information object
# File lib/env_pull_request/base.rb, line 30 def initialize @pull_request_id = if block_given? yield || fetch_pull_request_id else fetch_pull_request_id end end
Public Instance Methods
fetch_pull_request_id()
click to toggle source
Fetch pull request id from environment variables
travis-ci.org:
ENV['TRAVIS_PULL_REQUEST']
circleci.com:
ENV['CIRCLE_PR_NUMBER']
bitrise.io:
ENV['BITRISE_PULL_REQUEST']
Jenkins GitHub pull request builder plugin:
ENV['ghprbPullId']
@return [Integer, nil] pull request id or nil
@see TestHelper.stash_env_pull_request
@see TestHelper.restore_env_pull_request
@see docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
Environment Variables - Travis CI
@see circleci.com/docs/environment-variables#building-pull-requests-that-come-from-forks
Environment variables - CircleCI
@see devcenter.bitrise.io/faq/available-environment-variables/
Environment variables - Bitrise
GitHub pull request builder plugin - Jenkins - Jenkins Wiki
# File lib/env_pull_request/base.rb, line 63 def fetch_pull_request_id if positive_integer_string? ENV['TRAVIS_PULL_REQUEST'] ENV['TRAVIS_PULL_REQUEST'].to_i elsif positive_integer_string? ENV['CIRCLE_PR_NUMBER'] ENV['CIRCLE_PR_NUMBER'].to_i elsif positive_integer_string? ENV['BITRISE_PULL_REQUEST'] ENV['BITRISE_PULL_REQUEST'].to_i elsif positive_integer_string? ENV['ghprbPullId'] ENV['ghprbPullId'].to_i end end
pull_request?()
click to toggle source
@return [Boolean] true if this is pull request
# File lib/env_pull_request/base.rb, line 76 def pull_request? !pull_request_id.nil? end