Class: TerraspaceCiBitbucket::Vars

Inherits:
Object
  • Object
show all
Defined in:
lib/terraspace_ci_bitbucket/vars.rb

Instance Method Summary collapse

Instance Method Details

#branch_nameObject



53
54
55
# File 'lib/terraspace_ci_bitbucket/vars.rb', line 53

def branch_name
  ENV['BITBUCKET_BRANCH']
end

#branch_urlObject



33
34
35
# File 'lib/terraspace_ci_bitbucket/vars.rb', line 33

def branch_url
  "#{host}/#{full_repo}/branch/#{branch_name}"
end

#build_idObject



65
66
67
# File 'lib/terraspace_ci_bitbucket/vars.rb', line 65

def build_id
  ENV['BITBUCKET_BUILD_NUMBER']
end

#build_typeObject



69
70
71
# File 'lib/terraspace_ci_bitbucket/vars.rb', line 69

def build_type
  'pull_request' if ENV['BITBUCKET_PR_ID']
end

#build_urlObject



41
42
43
# File 'lib/terraspace_ci_bitbucket/vars.rb', line 41

def build_url
  "#{repo_url}/addon/pipelines/home#!/results/#{build_id}"
end

#commit_urlObject



29
30
31
# File 'lib/terraspace_ci_bitbucket/vars.rb', line 29

def commit_url
  "#{host}/#{full_repo}/commits/#{sha}"
end

#dataObject

Hash of properties to store



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/terraspace_ci_bitbucket/vars.rb', line 4

def data
  {
    build_system: "bitbucket",
    host: host,
    full_repo: full_repo,
    branch_name: branch_name,
    # urls
    pr_url: pr_url,
    build_url: build_url,
    branch_url: branch_url,
    # additional properties
    build_type: build_type,   # required IE: pull_request or push
    pr_number: pr_number,  # set when build_type=pull_request
    sha: sha,
    # additional properties
    # commit_message: commit_message,
    build_id: build_id,
    build_number: ENV['REPLACE_ME'],
  }
end

#full_repoObject



61
62
63
# File 'lib/terraspace_ci_bitbucket/vars.rb', line 61

def full_repo
  ENV['BITBUCKET_REPO_FULL_NAME']
end

#hostObject



25
26
27
# File 'lib/terraspace_ci_bitbucket/vars.rb', line 25

def host
  ENV['BITBUCKET_HOST'] || 'https://bitbucket.org'
end

#pr_numberObject



45
46
47
# File 'lib/terraspace_ci_bitbucket/vars.rb', line 45

def pr_number
  ENV['BITBUCKET_PR_ID']
end

#pr_urlObject



37
38
39
# File 'lib/terraspace_ci_bitbucket/vars.rb', line 37

def pr_url
  "#{host}/#{full_repo}/pull-requests/#{pr_number}" if pr_number
end

#repo_urlObject



49
50
51
# File 'lib/terraspace_ci_bitbucket/vars.rb', line 49

def repo_url
  ENV['BITBUCKET_GIT_HTTP_ORIGIN']
end

#shaObject



57
58
59
# File 'lib/terraspace_ci_bitbucket/vars.rb', line 57

def sha
  ENV['BITBUCKET_COMMIT']
end