Module: TeamCity::Client::Builds

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

Overview

Defines methods related to builds

Instance Method Summary collapse

Instance Method Details

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

Get build details

Parameters:

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

    option keys, :id => build_id

Returns:

  • (Hashie::Mash)

    of build details



22
23
24
25
# File 'lib/teamcity/client/builds.rb', line 22

def build(options={})
  assert_options(options)
  get("builds/#{locator(options)}")
end

#build_artifacts(build_id) ⇒ Array<Hashie::Mash>

Get build artifacts

Parameters:

  • build_id (String)

Returns:

  • (Array<Hashie::Mash>)


60
61
62
63
# File 'lib/teamcity/client/builds.rb', line 60

def build_artifacts(build_id)
  response = get("builds/#{build_id}/artifacts")
  response['files']
end

#build_pinned?(id) ⇒ Boolean

Tells you whether or not a build is pinned

Parameters:

  • id (String)

    build to check if it is pinned

Returns:

  • (Boolean)

    whether the build is pinned or not



50
51
52
53
54
# File 'lib/teamcity/client/builds.rb', line 50

def build_pinned?(id)
  path = "builds/#{id}/pin"
  response = get(path, :accept => :text, :content_type => :text)
  response == 'true'
end

#build_statistics(build_id) ⇒ Array<Hashie::Mash>

Get build statistics

Parameters:

  • build_id (String)

Returns:

  • (Array<Hashie::Mash>)


41
42
43
44
# File 'lib/teamcity/client/builds.rb', line 41

def build_statistics(build_id)
  response = get("builds/#{build_id}/statistics")
  response['property']
end

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

Get the build tags

Parameters:

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

    option keys, :id => build_id

Returns:

  • (Array<Hashie::Mash>)

    or empty array if no tags exist



31
32
33
34
35
# File 'lib/teamcity/client/builds.rb', line 31

def build_tags(options={})
  assert_options(options)
  response = get("builds/#{locator(options)}/tags")
  response.fetch(:tag)
end

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

List of builds

Parameters:

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

    list of build locators to filter build results on

Returns:

  • (Array<Hashie::Mash>)

    of builds (empty array if no builds exist)



12
13
14
15
16
# File 'lib/teamcity/client/builds.rb', line 12

def builds(options={})
  url_params = options.empty? ? '' : "?locator=#{locator(options)}"
  response = get("builds#{url_params}")
  response.build
end

#pin_build(id, comment = '') ⇒ nil

Pin a build

Parameters:

  • id (String)

    build to pin

  • comment (String) (defaults to: '')

    provide a comment to the pin

Returns:

  • (nil)


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

def pin_build(id, comment='')
  path = "builds/#{id}/pin"
  put(path, :accept => :text, :content_type => :text) do |req|
    req.body = comment
  end
  return nil
end

#unpin_build(id) ⇒ nil

Unpin a build

Parameters:

  • id (String)

    build to unpin

Returns:

  • (nil)


86
87
88
89
# File 'lib/teamcity/client/builds.rb', line 86

def unpin_build(id)
  path = "builds/#{id}/pin"
  delete(path, :content_type => :text)
end