Class: EnvBranch::Base
- Inherits:
-
Object
- Object
- EnvBranch::Base
- Defined in:
- lib/env_branch/base.rb
Overview
Branch information object from environment variable
Instance Attribute Summary collapse
-
#branch_name ⇒ String?
readonly
Branch name or nil.
Instance Method Summary collapse
-
#branch? ⇒ Boolean
True if this has branch name.
-
#fetch_branch_name ⇒ String?
Fetch branch name from environment variables.
-
#initialize ⇒ Base
constructor
Build branch information object from environment variables.
Constructor Details
Instance Attribute Details
#branch_name ⇒ String? (readonly)
Returns branch name or nil.
5 6 7 |
# File 'lib/env_branch/base.rb', line 5 def branch_name @branch_name end |
Instance Method Details
#branch? ⇒ Boolean
Returns true if this has branch name.
80 81 82 |
# File 'lib/env_branch/base.rb', line 80 def branch? !branch_name.nil? end |
#fetch_branch_name ⇒ String?
Fetch branch name from environment variables
travis-ci.org:
ENV['TRAVIS_BRANCH']
circleci.com:
ENV['CIRCLE_BRANCH']
bitrise.io:
ENV['BITRISE_GIT_BRANCH']
GitHub pull request builder plugin (for Jenkins):
ENV['ghprbSourceBranch']
Git plugin (for Jenkins):
ENV['GIT_BRANCH']
65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/env_branch/base.rb', line 65 def fetch_branch_name if ENV['TRAVIS_BRANCH'] && !ENV['TRAVIS_BRANCH'].empty? ENV['TRAVIS_BRANCH'] elsif ENV['CIRCLE_BRANCH'] && !ENV['CIRCLE_BRANCH'].empty? ENV['CIRCLE_BRANCH'] elsif ENV['BITRISE_GIT_BRANCH'] && !ENV['BITRISE_GIT_BRANCH'].empty? ENV['BITRISE_GIT_BRANCH'] elsif ENV['ghprbSourceBranch'] && !ENV['ghprbSourceBranch'].empty? ENV['ghprbSourceBranch'] elsif ENV['GIT_BRANCH'] && !ENV['GIT_BRANCH'].empty? ENV['GIT_BRANCH'] end end |