Class: CiToolkit::Build
- Inherits:
-
Object
- Object
- CiToolkit::Build
- Defined in:
- lib/ci_toolkit/build.rb
Overview
Provides utility for a build
Instance Method Summary collapse
- #from_cron_job? ⇒ Boolean
- #from_develop? ⇒ Boolean
- #from_master? ⇒ Boolean
- #from_pull_request? ⇒ Boolean
- #from_release? ⇒ Boolean
-
#initialize(git = CiToolkit::Git.new, env = CiToolkit::BitriseEnv.new) ⇒ Build
constructor
A new instance of Build.
- #number ⇒ Object
- #tag_name(build_number = nil) ⇒ Object
- #url ⇒ Object
- #version ⇒ Object
Constructor Details
Instance Method Details
#from_cron_job? ⇒ Boolean
38 39 40 |
# File 'lib/ci_toolkit/build.rb', line 38 def from_cron_job? @env.build_from_cron_job? end |
#from_develop? ⇒ Boolean
26 27 28 |
# File 'lib/ci_toolkit/build.rb', line 26 def from_develop? !!(@git.branch =~ /^develop$/) end |
#from_master? ⇒ Boolean
34 35 36 |
# File 'lib/ci_toolkit/build.rb', line 34 def from_master? !!(@git.branch =~ /^master$/) end |
#from_pull_request? ⇒ Boolean
22 23 24 |
# File 'lib/ci_toolkit/build.rb', line 22 def from_pull_request? @env.build_from_pr? end |
#from_release? ⇒ Boolean
30 31 32 |
# File 'lib/ci_toolkit/build.rb', line 30 def from_release? !!(@git.branch =~ %r{^release/.*}) end |
#number ⇒ Object
18 19 20 |
# File 'lib/ci_toolkit/build.rb', line 18 def number @env.build_number || Time.now.to_i.to_s end |
#tag_name(build_number = nil) ⇒ Object
52 53 54 55 56 |
# File 'lib/ci_toolkit/build.rb', line 52 def tag_name(build_number = nil) return version.to_s if version.include?("-build.") || build_number.nil? "#{version}-build.#{build_number}" end |
#url ⇒ Object
14 15 16 |
# File 'lib/ci_toolkit/build.rb', line 14 def url @env.build_url end |
#version ⇒ Object
42 43 44 45 46 47 48 49 50 |
# File 'lib/ci_toolkit/build.rb', line 42 def version version = @git.branch.split("/").last return version if !version.nil? && Gem::Version.correct?(version) return @git.latest_tag if Gem::Version.correct?(@git.latest_tag) raise StandardError, "Incorrect version supplied. You need to build from a valid \ release branch with semantic versioning, eg. release/x.y.z" end |