Module: TeamCity::Client::BuildTypes

Included in:
TeamCity::Client
Defined in:
lib/teamcity/client/build_types.rb

Overview

Defines methods related to build types (or build configurations)

Instance Method Summary collapse

Instance Method Details

#attach_vcs_root(buildtype_id, vcs_root_id) ⇒ Hashie::Mash

Attach a vcs root to a build type (build configuration_)

Parameters:

  • buildtype_id (String)

    the buildtype id

  • vcs_root_id (String, Numeric)

    id of vcs root

Returns:

  • (Hashie::Mash)

    vcs root object that was attached



110
111
112
113
114
115
116
117
118
119
# File 'lib/teamcity/client/build_types.rb', line 110

def attach_vcs_root(buildtype_id, vcs_root_id)
  builder = Builder::XmlMarkup.new
  builder.tag!('vcs-root-entry'.to_sym) do |node|
    node.tag!('vcs-root'.to_sym, :id => vcs_root_id)
  end
  post("buildTypes/#{buildtype_id}/vcs-root-entries") do |req|
    req.headers['Content-Type'] = 'application/xml'
    req.body = builder.target!
  end
end

#buildtype(options = {}) ⇒ Hashie::Mash

Get build configuration details

Parameters:

  • options (Hash) (defaults to: {})

    option keys, :id => buildtype_id

Returns:

  • (Hashie::Mash)

    of build configuration details



24
25
26
27
# File 'lib/teamcity/client/build_types.rb', line 24

def buildtype(options={})
  assert_options(options)
  get("buildTypes/#{locator(options)}")
end

#buildtype_agent_requirements(options = {}) ⇒ Array<Hashie::Mash>

Get build configuration agent_requirements

Parameters:

  • options (Hash) (defaults to: {})

    option keys, :id => buildtype_id

Returns:

  • (Array<Hashie::Mash>)

    of build configuration agent_requirements



99
# File 'lib/teamcity/client/build_types.rb', line 99

make_method :agent_requirements

#buildtype_artifact_dependencies(options = {}) ⇒ Array<Hashie::Mash>

Get build configuration artifact_dependencies

Parameters:

  • options (Hash) (defaults to: {})

    option keys, :id => buildtype_id

Returns:

  • (Array<Hashie::Mash>)

    of build configuration artifact_dependencies



100
# File 'lib/teamcity/client/build_types.rb', line 100

make_method :artifact_dependencies

#buildtype_features(options = {}) ⇒ Array<Hashie::Mash>

Get build configuration features

Parameters:

  • options (Hash) (defaults to: {})

    option keys, :id => buildtype_id

Returns:

  • (Array<Hashie::Mash>)

    of build configuration features



96
# File 'lib/teamcity/client/build_types.rb', line 96

make_method :features

#buildtype_investigations(buildtype_id) ⇒ Array<Hashie::Mash>

Get investigation info for build configuration

Parameters:

  • buildtype_id (String)

    the buildtype id

Returns:

  • (Array<Hashie::Mash>)

    of build investigation info



63
64
65
66
# File 'lib/teamcity/client/build_types.rb', line 63

def buildtype_investigations(buildtype_id)
  response = get("buildTypes/#{buildtype_id}/investigations")
  response['investigation']
end

#buildtype_parameters(options = {}) ⇒ Array<Hashie::Mash>

Get build configuration parameters

Parameters:

  • options (Hash) (defaults to: {})

    option keys, :id => buildtype_id

Returns:

  • (Array<Hashie::Mash>)

    of build configuration parameters



53
54
55
56
57
# File 'lib/teamcity/client/build_types.rb', line 53

def buildtype_parameters(options={})
  assert_options(options)
  response = get("buildTypes/#{locator(options)}/parameters")
  response['property']
end

#buildtype_settings(options = {}) ⇒ Array<Hashie::Mash>

Get build configuration settings

Parameters:

  • options (Hash) (defaults to: {})

    option keys, :id => buildtype_id

Returns:

  • (Array<Hashie::Mash>)

    of build configuration settings



43
44
45
46
47
# File 'lib/teamcity/client/build_types.rb', line 43

def buildtype_settings(options={})
  assert_options(options)
  response = get("buildTypes/#{locator(options)}/settings")
  response['property']
end

#buildtype_snapshot_dependencies(options = {}) ⇒ Array<Hashie::Mash>

Get build configuration snapshot_dependencies

Parameters:

  • options (Hash) (defaults to: {})

    option keys, :id => buildtype_id

Returns:

  • (Array<Hashie::Mash>)

    of build configuration snapshot_dependencies



101
# File 'lib/teamcity/client/build_types.rb', line 101

make_method :snapshot_dependencies

#buildtype_state(options = {}) ⇒ String

Get whether the build is paused or not

Parameters:

  • options (Hash) (defaults to: {})

    option keys, :id => buildtype_id

Returns:

  • (String)

    ‘true’ or ‘false’ on whether the build is paused



33
34
35
36
37
# File 'lib/teamcity/client/build_types.rb', line 33

def buildtype_state(options={})
  assert_options(options)
  path = "buildTypes/#{locator(options)}/paused"
  get(path, :accept => :text, :content_type => :text)
end

#buildtype_steps(options = {}) ⇒ Array<Hashie::Mash>

Get build configuration steps

Parameters:

  • options (Hash) (defaults to: {})

    option keys, :id => buildtype_id

Returns:

  • (Array<Hashie::Mash>)

    of build configuration steps



98
# File 'lib/teamcity/client/build_types.rb', line 98

make_method :steps

#buildtype_template(options = {}) ⇒ Hashie::Mash?

Get template associated with build configuration

Parameters:

  • options (Hash) (defaults to: {})

    option keys, :id => buildtype_id

Returns:

  • (Hashie::Mash, nil)

    of build configuration parameters or nil if



72
73
74
75
76
77
78
79
# File 'lib/teamcity/client/build_types.rb', line 72

def buildtype_template(options={})
  assert_options(options)
  begin
    get("buildTypes/#{locator(options)}/template")
  rescue StandardError => e
    /No template associated/.match(e.to_s) ? nil : raise
  end
end

#buildtype_triggers(options = {}) ⇒ Array<Hashie::Mash>

Get build configuration triggers

Parameters:

  • options (Hash) (defaults to: {})

    option keys, :id => buildtype_id

Returns:

  • (Array<Hashie::Mash>)

    of build configuration triggers



97
# File 'lib/teamcity/client/build_types.rb', line 97

make_method :triggers

#buildtype_vcs_root_entries(options = {}) ⇒ Array<Hashie::Mash>

Get build configuration vcs_root_entries

Parameters:

  • options (Hash) (defaults to: {})

    option keys, :id => buildtype_id

Returns:

  • (Array<Hashie::Mash>)

    of build configuration vcs_root_entries



102
# File 'lib/teamcity/client/build_types.rb', line 102

make_method :vcs_root_entries

#buildtypesArray<Hashie::Mash>?

List of build types

Returns:

  • (Array<Hashie::Mash>, nil)

    of buildtypes or nil if no buildtypes exist



15
16
17
18
# File 'lib/teamcity/client/build_types.rb', line 15

def buildtypes
  response = get('buildTypes')
  response['buildType']
end

#create_agent_requirement(buildtype_id, parameter_name, parameter_value, condition) ⇒ Hashie::Mash

Note:

Check the TeamCity UI for supported conditions

Create a buildtype agent requirement (Create)

Examples:

Create a condition where a system property equals something

TeamCity.create_agent_requirement('bt1', 'system.os.name', 'Linux', 'equals')

Parameters:

  • buildtype_id (String)

    the buildtype id

  • parameter_name (String)

    name of the parameter to set

  • parameter_value (String)

    value of the parameter

  • condition (String)

    the condition for which to check against

Returns:

  • (Hashie::Mash)


157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/teamcity/client/build_types.rb', line 157

def create_agent_requirement(buildtype_id, parameter_name, parameter_value, condition)
  builder = Builder::XmlMarkup.new
  builder.tag!('agent-requirement'.to_sym, :id => parameter_name, :type => condition) do |node|
    node.properties do |p|
      p.property(:name => 'property-name', :value => parameter_name)
      p.property(:name => 'property-value', :value => parameter_value)
    end
  end
  path = "buildTypes/#{buildtype_id}/agent-requirements"
  post(path, :accept => :json, :content_type => :xml) do |req|
    req.body = builder.target!
  end
end

#delete_agent_requirement(buildtype_id, parameter_name) ⇒ nil

Delete an agent requirement for a buildtype

Parameters:

  • buildtype_id (String)

    the buildtype_id

  • parameter_name (String)

    name of the requirement to delete

Returns:

  • (nil)


176
177
178
# File 'lib/teamcity/client/build_types.rb', line 176

def delete_agent_requirement(buildtype_id, parameter_name)
  delete("buildTypes/#{buildtype_id}/agent-requirements/#{parameter_name}")
end

#delete_buildtype(buildtype_id) ⇒ nil

Delete buildtype (build configuration)

Parameters:

  • buildtype_id (String)

    the id of the buildtype

Returns:

  • (nil)


204
205
206
# File 'lib/teamcity/client/build_types.rb', line 204

def delete_buildtype(buildtype_id)
  delete("buildTypes/#{buildtype_id}")
end

#delete_buildtype_parameter(buildtype_id, parameter_name) ⇒ nil

Delete a buildtype parameter

Parameters:

  • buildtype_id (String)

    the buildtype id

  • parameter_name (String)

    name of the parameter to delete

Returns:

  • (nil)


140
141
142
143
# File 'lib/teamcity/client/build_types.rb', line 140

def delete_buildtype_parameter(buildtype_id, parameter_name)
  path = "buildTypes/#{buildtype_id}/parameters/#{parameter_name}"
  delete(path, :accept => :text, :content_type => :text)
end

#set_build_step_field(buildtype_id, step_id, field_name, field_value) ⇒ nil

Set build step field

Parameters:

  • buildtype_id (String)

    the id of the buildtype

  • step_id (String)

    the id of the build step

  • field_name (String)

    the name of the field to set

  • field_value (String)

    the value to set the field name to

Returns:

  • (nil)


215
216
217
218
219
220
# File 'lib/teamcity/client/build_types.rb', line 215

def set_build_step_field(buildtype_id, step_id, field_name, field_value)
  path = "buildTypes/#{buildtype_id}/steps/#{step_id}/#{field_name}"
  put(path, :accept => :text, :content_type => :text) do |req|
    req.body = field_value
  end
end

#set_buildtype_field(buildtype_id, field_name, field_value) ⇒ Object

Set a buildtype field

Examples:

Change buildtype name

TeamCity.set_buildtype_field('bt3', 'name', 'new-name')

Set buildtype description

TeamCity.set_buildtype_field('bt3', 'description', 'new-description')

Pause/Unpause a buildtype

Teamcity.set_buildtype_field('buildtype', 'paused', 'true|false')

Parameters:

  • buidltype_id (String)

    the buildtype id

  • field_name (String)

    the field name

  • field_value (String)

    the value to set the field to



193
194
195
196
197
198
# File 'lib/teamcity/client/build_types.rb', line 193

def set_buildtype_field(buildtype_id, field_name, field_value)
  path = "buildTypes/#{buildtype_id}/#{field_name}"
  put(path, :accept => :text, :content_type => :text) do |req|
    req.body = field_value
  end
end

#set_buildtype_parameter(buildtype_id, parameter_name, parameter_value) ⇒ Object

Set a buildtype parameter (Create or Update)

Parameters:

  • buildtype_id (String)

    the buildtype id

  • parameter_name (String)

    name of the parameter to set

  • parameter_value (String)

    value of the parameter



128
129
130
131
132
133
# File 'lib/teamcity/client/build_types.rb', line 128

def set_buildtype_parameter(buildtype_id, parameter_name, parameter_value)
  path = "buildTypes/#{buildtype_id}/parameters/#{parameter_name}"
  put(path, :accept => :text, :content_type => :text) do |req|
    req.body = parameter_value
  end
end