class Thegarage::Gitx::Cli::BuildtagCommand

Public Instance Methods

buildtag() click to toggle source
# File lib/thegarage/gitx/cli/buildtag_command.rb, line 11
def buildtag
  fail "Unknown branch. Environment variables TRAVIS_BRANCH or CI_BRANCH are required" unless branch_name
  fail "Branch must be one of the supported taggable branches: #{config.taggable_branches}" unless config.taggable_branch?(branch_name)

  label = "buildtag generated by build #{build_number}"
  create_build_tag(branch_name, label)
end

Private Instance Methods

branch_name() click to toggle source

pull the current branch name from environment variables supports Travis CI or Codeship variables see www.codeship.io/documentation/continuous-integration/set-environment-variables/

# File lib/thegarage/gitx/cli/buildtag_command.rb, line 24
def branch_name
  ENV['TRAVIS_BRANCH'] || ENV['CI_BRANCH']
end
build_number() click to toggle source
# File lib/thegarage/gitx/cli/buildtag_command.rb, line 28
def build_number
  ENV['TRAVIS_BUILD_NUMBER'] || ENV['CI_BUILD_NUMBER']
end
create_build_tag(branch, label) click to toggle source
# File lib/thegarage/gitx/cli/buildtag_command.rb, line 32
def create_build_tag(branch, label)
  timestamp = Time.now.utc.strftime '%Y-%m-%d-%H-%M-%S'
  git_tag = "build-#{branch}-#{timestamp}"
  run_cmd "git tag #{git_tag} -a -m '#{label}'"
  run_cmd "git push origin #{git_tag}"
end