Class: Datadog::CI::Ext::Environment::Providers::Azure

Inherits:
Base
  • Object
show all
Defined in:
lib/datadog/ci/ext/environment/providers/azure.rb

Overview

Instance Attribute Summary

Attributes inherited from Base

#env

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#additional_tags, #git_branch, #git_commit_author_date, #git_commit_committer_date, #git_commit_committer_email, #git_commit_committer_name, #git_tag, #initialize, #node_labels, #node_name

Constructor Details

This class inherits a constructor from Datadog::CI::Ext::Environment::Providers::Base

Class Method Details

.handles?(env) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 15

def self.handles?(env)
  env.key?("TF_BUILD")
end

Instance Method Details

#ci_env_varsObject



83
84
85
86
87
88
89
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 83

def ci_env_vars
  {
    "SYSTEM_TEAMPROJECTID" => env["SYSTEM_TEAMPROJECTID"],
    "BUILD_BUILDID" => env["BUILD_BUILDID"],
    "SYSTEM_JOBID" => env["SYSTEM_JOBID"]
  }.to_json
end

#git_branch_or_tagObject



67
68
69
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 67

def git_branch_or_tag
  env["SYSTEM_PULLREQUEST_SOURCEBRANCH"] || env["BUILD_SOURCEBRANCH"] || env["BUILD_SOURCEBRANCHNAME"]
end

#git_commit_author_emailObject



75
76
77
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 75

def git_commit_author_email
  env["BUILD_REQUESTEDFOREMAIL"]
end

#git_commit_author_nameObject



71
72
73
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 71

def git_commit_author_name
  env["BUILD_REQUESTEDFORID"]
end

#git_commit_messageObject



79
80
81
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 79

def git_commit_message
  env["BUILD_SOURCEVERSIONMESSAGE"]
end

#git_commit_shaObject



63
64
65
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 63

def git_commit_sha
  env["SYSTEM_PULLREQUEST_SOURCECOMMITID"] || env["BUILD_SOURCEVERSION"]
end

#git_repository_urlObject



59
60
61
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 59

def git_repository_url
  env["SYSTEM_PULLREQUEST_SOURCEREPOSITORYURI"] || env["BUILD_REPOSITORY_URI"]
end

#job_nameObject



55
56
57
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 55

def job_name
  env["SYSTEM_JOBDISPLAYNAME"]
end

#job_urlObject



29
30
31
32
33
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 29

def job_url
  return unless url_defined?

  @job_url ||= "#{pipeline_url}&view=logs&j=#{env["SYSTEM_JOBID"]}&t=#{env["SYSTEM_TASKINSTANCEID"]}"
end

#pipeline_idObject



39
40
41
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 39

def pipeline_id
  build_id
end

#pipeline_nameObject



47
48
49
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 47

def pipeline_name
  env["BUILD_DEFINITIONNAME"]
end

#pipeline_numberObject



43
44
45
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 43

def pipeline_number
  build_id
end

#pipeline_urlObject



23
24
25
26
27
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 23

def pipeline_url
  return unless url_defined?

  @pipeline_url ||= "#{team_foundation_server_uri}#{team_project_id}/_build/results?buildId=#{build_id}"
end

#provider_nameObject



19
20
21
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 19

def provider_name
  Provider::AZURE
end

#stage_nameObject



51
52
53
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 51

def stage_name
  env["SYSTEM_STAGEDISPLAYNAME"]
end

#workspace_pathObject



35
36
37
# File 'lib/datadog/ci/ext/environment/providers/azure.rb', line 35

def workspace_path
  env["BUILD_SOURCESDIRECTORY"]
end