Class: TerraspaceCiAzure::Interface
- Inherits:
-
Object
- Object
- TerraspaceCiAzure::Interface
- Defined in:
- lib/terraspace_ci_azure/interface.rb
Instance Method Summary collapse
-
#base_project_url ⇒ Object
removes the user@ part IE: BUILD_REPOSITORY_URI=[email protected]/tongueroo/infra-project/_git/infra-ci.
- #base_repo_url ⇒ Object
- #branch_name ⇒ Object
- #branch_url ⇒ Object
- #build_id ⇒ Object
- #build_type ⇒ Object
-
#build_url ⇒ Object
IE: BUILD_BUILDID=74 dev.azure.com/tongueroo/infra-project/_build/results?buildId=152&view=results.
- #commit_url ⇒ Object
-
#full_repo ⇒ Object
IE: BUILD_REPOSITORY_URI=[email protected]/tongueroo/infra-project/_git/infra-ci.
-
#host ⇒ Object
IE: BUILD_REPOSITORY_URI=[email protected]/tongueroo/infra-project/_git/infra-ci.
-
#pr_number ⇒ Object
IE: SYSTEM_PULLREQUEST_PULLREQUESTID=2.
- #pr_url ⇒ Object
- #sha ⇒ Object
-
#vars ⇒ Object
Interface method.
Instance Method Details
#base_project_url ⇒ Object
removes the user@ part IE: BUILD_REPOSITORY_URI=[email protected]/tongueroo/infra-project/_git/infra-ci
57 58 59 60 61 |
# File 'lib/terraspace_ci_azure/interface.rb', line 57 def base_project_url uri = URI(ENV['BUILD_REPOSITORY_URI']) base_path = uri.path.split('/')[0..2].join('/') "#{uri.scheme}://#{uri.host}#{base_path}" end |
#base_repo_url ⇒ Object
63 64 65 66 |
# File 'lib/terraspace_ci_azure/interface.rb', line 63 def base_repo_url uri = URI(ENV['BUILD_REPOSITORY_URI']) "#{uri.scheme}://#{uri.host}#{uri.path}" end |
#branch_name ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/terraspace_ci_azure/interface.rb', line 28 def branch_name if pr_number = ENV['BUILD_SOURCEVERSIONMESSAGE'] md = .match(/Merge pull request \d+ from (.*) into (.*)/) if md # IE: BUILD_SOURCEVERSIONMESSAGE=Merge pull request 2 from feature into main # Its a bit weird but with azure repos with check policy trigger md[1] else # GitHub and Bitbucket PR has actual branch though # IE: SYSTEM_PULLREQUEST_SOURCEBRANCH=feature end else # push ENV['BUILD_SOURCEBRANCHNAME'] end end |
#branch_url ⇒ Object
110 111 112 |
# File 'lib/terraspace_ci_azure/interface.rb', line 110 def branch_url "#{base_repo_url}?version=GB#{branch_name}" end |
#build_id ⇒ Object
85 86 87 |
# File 'lib/terraspace_ci_azure/interface.rb', line 85 def build_id ENV['BUILD_BUILDID'] end |
#build_type ⇒ Object
76 77 78 |
# File 'lib/terraspace_ci_azure/interface.rb', line 76 def build_type ENV['SYSTEM_PULLREQUEST_PULLREQUESTID'] ? 'pull_request' : 'push' end |
#build_url ⇒ Object
IE: BUILD_BUILDID=74 dev.azure.com/tongueroo/infra-project/_build/results?buildId=152&view=results
99 100 101 102 |
# File 'lib/terraspace_ci_azure/interface.rb', line 99 def build_url return unless build_id "#{base_project_url}/_build/results?buildId=#{build_id}&view=results" end |
#commit_url ⇒ Object
105 106 107 |
# File 'lib/terraspace_ci_azure/interface.rb', line 105 def commit_url "#{base_repo_url}/commit/#{sha}" end |
#full_repo ⇒ Object
IE: BUILD_REPOSITORY_URI=[email protected]/tongueroo/infra-project/_git/infra-ci
69 70 71 72 73 74 |
# File 'lib/terraspace_ci_azure/interface.rb', line 69 def full_repo uri = URI(ENV['BUILD_REPOSITORY_URI']) org = uri.path.split('/')[1] # since there's a leading / repo = ENV['BUILD_REPOSITORY_NAME'] # tongueroo "#{org}/#{repo}" end |
#host ⇒ Object
IE: BUILD_REPOSITORY_URI=[email protected]/tongueroo/infra-project/_git/infra-ci
50 51 52 53 |
# File 'lib/terraspace_ci_azure/interface.rb', line 50 def host uri = URI(ENV['BUILD_REPOSITORY_URI']) "#{uri.scheme}://#{uri.host}" end |
#pr_number ⇒ Object
IE: SYSTEM_PULLREQUEST_PULLREQUESTID=2
81 82 83 |
# File 'lib/terraspace_ci_azure/interface.rb', line 81 def pr_number ENV['SYSTEM_PULLREQUEST_PULLREQUESTID'] end |
#pr_url ⇒ Object
91 92 93 94 95 |
# File 'lib/terraspace_ci_azure/interface.rb', line 91 def pr_url return unless pr_number uri = URI(ENV['BUILD_REPOSITORY_URI']) "#{base_repo_url}/pullrequest/#{pr_number}" end |
#sha ⇒ Object
45 46 47 |
# File 'lib/terraspace_ci_azure/interface.rb', line 45 def sha ENV['BUILD_SOURCEVERSION'] end |
#vars ⇒ Object
Interface method. Returns Hash of properties.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/terraspace_ci_azure/interface.rb', line 6 def vars { build_system: "azure", host: host, full_repo: full_repo, branch_name: branch_name, # urls pr_url: pr_url, build_url: build_url, branch_url: branch_url, commit_url: commit_url, # additional properties build_type: build_type, pr_number: pr_number, sha: sha, # additional properties # commit_message: ENV['REPLACE_ME'], build_id: build_id, build_number: ENV['BUILD_BUILDNUMBER'], # IE: BUILD_BUILDNUMBER=20220715.12 } end |