Class: TeamcityApi

Inherits:
Object
  • Object
show all
Includes:
API
Defined in:
lib/teamcity_api.rb

Instance Attribute Summary

Attributes included from API

#api

Instance Method Summary collapse

Methods included from API

#create_api, #parsed_response, #request

Constructor Details

#initializeTeamcityApi

Returns a new instance of TeamcityApi.



4
5
6
# File 'lib/teamcity_api.rb', line 4

def initialize
  create_api( ConfigStore.teamcity )
end

Instance Method Details

#build_queueObject



8
9
10
# File 'lib/teamcity_api.rb', line 8

def build_queue
  request(:get, 'buildQueue')
end

#create_build(build_config_id, properties = {}) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/teamcity_api.rb', line 12

def create_build(build_config_id, properties={})
  properties_string = ""
  properties.each_pair do |k,v|
    properties_string << "<property name='#{k}' value='#{v}'/>\n"
  end
  data = "
    <build>
      <buildType id='#{build_config_id}'/>
    <properties>
      #{properties_string}
    </properties>
    </build>
  "
  request(:post, 'buildQueue', data, "xml")
end

#projects(parent_id = nil) ⇒ Object



32
33
34
35
36
37
38
39
# File 'lib/teamcity_api.rb', line 32

def projects(parent_id=nil)
  list = Nokogiri::XML.parse(request(:get, 'projects').body)
  if parent_id
    (list.xpath '//project').select {|e| e.attributes['parentProjectId'].to_s ==  parent_id}
  else
    list
  end
end

#set_project_parameter(project_id, parameter, value) ⇒ Object



28
29
30
# File 'lib/teamcity_api.rb', line 28

def set_project_parameter(project_id,parameter,value)
  request(:put, "projects/#{project_id}/parameters/#{parameter}", value, "text")
end