Class: Jets::Git::Azure
Instance Method Summary collapse
- #build_type ⇒ Object
-
#full_repo ⇒ Object
IE: BUILD_REPOSITORY_URI=[email protected]/tongueroo/infra-project/_git/infra-ci.
- #git_branch ⇒ Object
- #git_sha ⇒ Object
- #git_url ⇒ Object
-
#host ⇒ Object
IE: BUILD_REPOSITORY_URI=[email protected]/tongueroo/infra-project/_git/infra-ci.
- #info ⇒ Object
-
#pr_number ⇒ Object
IE: SYSTEM_PULLREQUEST_PULLREQUESTID=2.
Methods inherited from Base
Instance Method Details
#build_type ⇒ Object
60 61 62 |
# File 'lib/jets/git/azure.rb', line 60 def build_type ENV["SYSTEM_PULLREQUEST_PULLREQUESTID"] ? "pull_request" : "push" end |
#full_repo ⇒ Object
IE: BUILD_REPOSITORY_URI=[email protected]/tongueroo/infra-project/_git/infra-ci
48 49 50 51 52 53 |
# File 'lib/jets/git/azure.rb', line 48 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 |
#git_branch ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/jets/git/azure.rb', line 16 def git_branch 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 |
#git_sha ⇒ Object
33 34 35 |
# File 'lib/jets/git/azure.rb', line 33 def git_sha ENV["BUILD_SOURCEVERSION"] end |
#git_url ⇒ Object
37 38 39 |
# File 'lib/jets/git/azure.rb', line 37 def git_url "#{host}/#{full_repo}" end |
#host ⇒ Object
IE: BUILD_REPOSITORY_URI=[email protected]/tongueroo/infra-project/_git/infra-ci
42 43 44 45 |
# File 'lib/jets/git/azure.rb', line 42 def host uri = URI(ENV["BUILD_REPOSITORY_URI"]) "#{uri.scheme}://#{uri.host}" end |
#info ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/jets/git/azure.rb', line 3 def info info = { git_system: "azure", git_branch: git_branch, git_sha: git_sha, git_dirty: false # git_message: nil, # git_version: nil, } info[:git_url] = git_url if git_url info end |
#pr_number ⇒ Object
IE: SYSTEM_PULLREQUEST_PULLREQUESTID=2
56 57 58 |
# File 'lib/jets/git/azure.rb', line 56 def pr_number ENV["SYSTEM_PULLREQUEST_PULLREQUESTID"] end |