Class: CircleciDeploymentNotifier::BuildInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/circleci_deployment_notifier/build_info.rb

Overview

Gets build information from the environment. Expects and currently only works with builds of Github repositories.

Instance Method Summary collapse

Instance Method Details

#branch_nameObject



14
15
16
# File 'lib/circleci_deployment_notifier/build_info.rb', line 14

def branch_name
  ENV['CIRCLE_BRANCH']
end

#build_identifierObject



56
57
58
# File 'lib/circleci_deployment_notifier/build_info.rb', line 56

def build_identifier
  ENV['CIRCLE_BUILD_NUM']
end

#build_urlObject



60
61
62
# File 'lib/circleci_deployment_notifier/build_info.rb', line 60

def build_url
  ENV['CIRCLE_BUILD_URL']
end

#builder_iconObject



40
41
42
43
# File 'lib/circleci_deployment_notifier/build_info.rb', line 40

def builder_icon
  return unless builder_username
  "https://github.com/#{builder_username}.png"
end

#builder_urlObject



45
46
47
48
# File 'lib/circleci_deployment_notifier/build_info.rb', line 45

def builder_url
  return unless builder_username
  "https://github.com/#{builder_username}"
end

#builder_usernameObject



36
37
38
# File 'lib/circleci_deployment_notifier/build_info.rb', line 36

def builder_username
  ENV['CIRCLE_USERNAME']
end

#commit_browse_urlObject



10
11
12
# File 'lib/circleci_deployment_notifier/build_info.rb', line 10

def commit_browse_url
  "#{repository_url}/tree/#{commit_hash}"
end

#commit_hashObject



6
7
8
# File 'lib/circleci_deployment_notifier/build_info.rb', line 6

def commit_hash
  ENV['CIRCLE_SHA1']
end

#repository_urlObject



50
51
52
53
54
# File 'lib/circleci_deployment_notifier/build_info.rb', line 50

def repository_url
  ENV['CIRCLE_REPOSITORY_URL'].sub(/\Agit@([-\.a-z]+):(.+)\.git\z/) { |m|
    "https://#{$1}/#{$2}"
  }
end

#tag?Boolean

Returns:

  • (Boolean)


32
33
34
# File 'lib/circleci_deployment_notifier/build_info.rb', line 32

def tag?
  tag_name
end

#tag_nameObject



18
19
20
# File 'lib/circleci_deployment_notifier/build_info.rb', line 18

def tag_name
  ENV['CIRCLE_TAG']
end

#tag_release_notes_urlObject



27
28
29
30
# File 'lib/circleci_deployment_notifier/build_info.rb', line 27

def tag_release_notes_url
  return unless tag_name
  "#{repository_url}/releases/tag/#{tag_name}"
end

#tag_urlObject



22
23
24
25
# File 'lib/circleci_deployment_notifier/build_info.rb', line 22

def tag_url
  return unless tag_name
  "#{repository_url}/tree/#{tag_name}"
end