class Bcnd::CI
Constants
- DEFAULT_CONFIG
Attributes
branch[RW]
commit[RW]
github_token[RW]
mainline_heritage_token[RW]
quay_repository[RW]
quay_token[RW]
repository[RW]
stable_heritage_token[RW]
stage_config[RW]
Public Class Methods
new()
click to toggle source
# File lib/bcnd/ci.rb, line 21 def initialize load_ci_environment load_stage_config self.quay_token = ENV['QUAY_TOKEN'] self.github_token = ENV['GITHUB_TOKEN'] self.mainline_heritage_token = ENV['MAINLINE_HERITAGE_TOKEN'] self.stable_heritage_token = ENV['STABLE_HERITAGE_TOKEN'] self.quay_repository = ENV['QUAY_REPOSITORY'] || self.repository end
Public Instance Methods
ci_service()
click to toggle source
# File lib/bcnd/ci.rb, line 40 def ci_service if ENV['TRAVIS'] :travis elsif ENV['GITLAB_CI'] :gitlab_ci else :unknown end end
deploy_environment()
click to toggle source
# File lib/bcnd/ci.rb, line 65 def deploy_environment stage_config[deploy_stage][:environment] end
deploy_stage()
click to toggle source
# File lib/bcnd/ci.rb, line 58 def deploy_stage { mainline_branch => :mainline, stable_branch => :stable }[self.branch] end
mainline_branch()
click to toggle source
# File lib/bcnd/ci.rb, line 50 def mainline_branch stage_config[:mainline][:branch] end
pull_request?()
click to toggle source
# File lib/bcnd/ci.rb, line 31 def pull_request? case ci_service when :travis ENV['TRAVIS_PULL_REQUEST'] != 'false' when :gitlab_ci !!ENV['CI_MERGE_REQUEST_ID'] end end
stable_branch()
click to toggle source
# File lib/bcnd/ci.rb, line 54 def stable_branch stage_config[:stable][:branch] end
Private Instance Methods
load_ci_environment()
click to toggle source
# File lib/bcnd/ci.rb, line 71 def load_ci_environment case ci_service when :travis self.repository = ENV['TRAVIS_REPO_SLUG'] self.commit = ENV['TRAVIS_COMMIT'] self.branch = ENV['TRAVIS_BRANCH'] when :gitlab_ci self.repository = ENV['CI_PROJECT_PATH'] self.commit = ENV['CI_COMMIT_SHA'] self.branch = ENV['CI_COMMIT_REF_NAME'] end end
load_config_file()
click to toggle source
# File lib/bcnd/ci.rb, line 98 def load_config_file file = File.read('barcelona.yml') YAML.load(file)["bcnd"] || {} rescue Errno::ENOENT => e {} end
load_stage_config()
click to toggle source
# File lib/bcnd/ci.rb, line 84 def load_stage_config config = DEFAULT_CONFIG.merge(load_config_file) self.stage_config = { mainline: { branch: config["mainline_branch"], environment: config["mainline_environment"] }, stable: { branch: config["stable_branch"], environment: config["stable_environment"] } } end