Class: Bcnd::CI
- Inherits:
-
Object
- Object
- Bcnd::CI
- Defined in:
- lib/bcnd/ci.rb
Constant Summary collapse
- DEFAULT_CONFIG =
{ "mainline_branch" => "master", "mainline_environment" => "staging", "stable_branch" => "production", "stable_environment" => "production" }
Instance Attribute Summary collapse
-
#branch ⇒ Object
Returns the value of attribute branch.
-
#commit ⇒ Object
Returns the value of attribute commit.
-
#github_token ⇒ Object
Returns the value of attribute github_token.
-
#mainline_heritage_token ⇒ Object
Returns the value of attribute mainline_heritage_token.
-
#quay_repository ⇒ Object
Returns the value of attribute quay_repository.
-
#quay_token ⇒ Object
Returns the value of attribute quay_token.
-
#repository ⇒ Object
Returns the value of attribute repository.
-
#stable_heritage_token ⇒ Object
Returns the value of attribute stable_heritage_token.
-
#stage_config ⇒ Object
Returns the value of attribute stage_config.
Instance Method Summary collapse
- #ci_service ⇒ Object
- #deploy_environment ⇒ Object
- #deploy_stage ⇒ Object
-
#initialize ⇒ CI
constructor
A new instance of CI.
- #mainline_branch ⇒ Object
- #pull_request? ⇒ Boolean
- #stable_branch ⇒ Object
Constructor Details
#initialize ⇒ CI
Returns a new instance of CI.
21 22 23 24 25 26 27 28 29 |
# 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 |
Instance Attribute Details
#branch ⇒ Object
Returns the value of attribute branch.
11 12 13 |
# File 'lib/bcnd/ci.rb', line 11 def branch @branch end |
#commit ⇒ Object
Returns the value of attribute commit.
11 12 13 |
# File 'lib/bcnd/ci.rb', line 11 def commit @commit end |
#github_token ⇒ Object
Returns the value of attribute github_token.
11 12 13 |
# File 'lib/bcnd/ci.rb', line 11 def github_token @github_token end |
#mainline_heritage_token ⇒ Object
Returns the value of attribute mainline_heritage_token.
11 12 13 |
# File 'lib/bcnd/ci.rb', line 11 def mainline_heritage_token @mainline_heritage_token end |
#quay_repository ⇒ Object
Returns the value of attribute quay_repository.
11 12 13 |
# File 'lib/bcnd/ci.rb', line 11 def quay_repository @quay_repository end |
#quay_token ⇒ Object
Returns the value of attribute quay_token.
11 12 13 |
# File 'lib/bcnd/ci.rb', line 11 def quay_token @quay_token end |
#repository ⇒ Object
Returns the value of attribute repository.
11 12 13 |
# File 'lib/bcnd/ci.rb', line 11 def repository @repository end |
#stable_heritage_token ⇒ Object
Returns the value of attribute stable_heritage_token.
11 12 13 |
# File 'lib/bcnd/ci.rb', line 11 def stable_heritage_token @stable_heritage_token end |
#stage_config ⇒ Object
Returns the value of attribute stage_config.
11 12 13 |
# File 'lib/bcnd/ci.rb', line 11 def stage_config @stage_config end |
Instance Method Details
#ci_service ⇒ Object
40 41 42 43 44 45 46 47 48 |
# 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 ⇒ Object
65 66 67 |
# File 'lib/bcnd/ci.rb', line 65 def deploy_environment stage_config[deploy_stage][:environment] end |
#deploy_stage ⇒ Object
58 59 60 61 62 63 |
# File 'lib/bcnd/ci.rb', line 58 def deploy_stage { mainline_branch => :mainline, stable_branch => :stable }[self.branch] end |
#mainline_branch ⇒ Object
50 51 52 |
# File 'lib/bcnd/ci.rb', line 50 def mainline_branch stage_config[:mainline][:branch] end |
#pull_request? ⇒ Boolean
31 32 33 34 35 36 37 38 |
# 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 ⇒ Object
54 55 56 |
# File 'lib/bcnd/ci.rb', line 54 def stable_branch stage_config[:stable][:branch] end |