class EnvBranch::Base
Branch information object from environment variable
Attributes
branch_name[R]
Public Class Methods
new() { ||| fetch_branch_name| ... }
click to toggle source
Build branch information object from environment variables
@overload initialize
@example without user defined block env_branch = EnvBranch::Base.new @return [Base] Branch information object
@overload initialize(&block)
@example with user defined block env_branch = EnvBranch::Base.new do if ENV['USER_DEFINED_BRANCH'] && !ENV['USER_DEFINED_BRANCH'].empty? ENV['USER_DEFINED_BRANCH'] end end @yield user defined block @return [Base] Branch information object
# File lib/env_branch/base.rb, line 28 def initialize @branch_name = if block_given? yield || fetch_branch_name else fetch_branch_name end end
Public Instance Methods
branch?()
click to toggle source
@return [Boolean] true if this has branch name
# File lib/env_branch/base.rb, line 80 def branch? !branch_name.nil? end
fetch_branch_name()
click to toggle source
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']
@return [String, nil] branch name or nil
@see TestHelper.stash_env_branch
@see TestHelper.restore_env_branch
@see docs.travis-ci.com/user/environment-variables/#Default-Environment-Variables
Environment Variables - Travis CI
@see circleci.com/docs/environment-variables#build-details
Environment variables - CircleCI
@see devcenter.bitrise.io/faq/available-environment-variables/
Environment variables - Bitrise
Environment Variables
@see wiki.jenkins-ci.org/display/JENKINS/Git+Plugin#GitPlugin-Environmentvariables
Environment variables
# 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