module TeamCity::Client::Projects

Defines methods related to projects

Public Instance Methods

copy_project(source_project_id, target_project_name, options={}) click to toggle source

Copy another project

@param source_project_id [String] id of the project you wish to copy @param target_project_name [String] name of the project you want to create @param options [Hash] copy project options @option options [Boolean] :copyAllAssociatedSettings copy all associated settings @options options [String] :parentProject used to define the parent project to create this project under (root will be use by default) @options options [String] :id to use for the new project @return [Hashie::Mash] project details

# File lib/teamcity/client/projects.rb, line 75
def copy_project(source_project_id, target_project_name, options={})
  attributes = {
    :name => target_project_name
  }

  payload = { 'sourceProject' => { locator: source_project_id } }.merge(attributes)

  post("projects", :content_type => :json, :accept => :json) do |req|
    req.body = payload.to_json
  end
end
create_project(name) click to toggle source

Create an empty project

@param name [String] Name of the project @return [Hashie::Mash] project details

# File lib/teamcity/client/projects.rb, line 60
def create_project(name)
  post("projects", :content_type => :text) do |req|
    req.body = name
  end
end
delete_project(project_id) click to toggle source

Delete a project

@param project_id [String] the id of the project @return [nil]

# File lib/teamcity/client/projects.rb, line 91
def delete_project(project_id)
  delete("projects/#{project_id}")
end
delete_project_parameter(project_id, parameter_name) click to toggle source

Delete a project parameter

@param project_id [String] the project id @param parameter_name [String] name of the parameter to delete @return [nil]

# File lib/teamcity/client/projects.rb, line 100
def delete_project_parameter(project_id, parameter_name)
  path = "projects/#{project_id}/parameters/#{parameter_name}"
  delete(path, :accept => :text)
  return nil
end
parent_project(options={}) click to toggle source

Get parent project

@param (see project) @return [Hashie::Mash] of the parent project details @rest_api_version >= 8.0

# File lib/teamcity/client/projects.rb, line 49
def parent_project(options={})
  assert_options(options)
  response = get("projects/#{locator(options)}/parentProject")
  return nil if response['id'] == '_Root'
  response
end
project(options={}) click to toggle source

Get project details

@param options [Hash] The options hash, @option options [String] :id the project id @return [Hashie::Mash] of project details

# File lib/teamcity/client/projects.rb, line 19
def project(options={})
  assert_options(options)
  get("projects/#{locator(options)}")
end
project_buildtypes(options={}) click to toggle source

List of Build Configurations of a project

@param (see project) @return [Array<Hashie::Mash> of build types (an empty array will be returne if none exist)

# File lib/teamcity/client/projects.rb, line 28
def project_buildtypes(options={})
  assert_options(options)
  response = get("projects/#{locator(options)}/buildTypes")
  response['buildType']
end
project_parameters(options={}) click to toggle source

List of parameters defined on a project

@param (see project) @return [Array<Hashie::Mash>] of parameters (empty if none are defined)

# File lib/teamcity/client/projects.rb, line 38
def project_parameters(options={})
  assert_options(options)
  response = get("projects/#{locator(options)}/parameters")
  response['property']
end
projects() click to toggle source

List of projects

@return [Array<Hashie::Mash>, nil] of projects or nil if no projects exist

# File lib/teamcity/client/projects.rb, line 9
def projects
  response = get('projects')
  response['project']
end
set_parent_project(project_id, parent_project_id) click to toggle source

Set a parent for a given project

@example Set project1 as parent for project2

TeamCity.set_parent_project('project2', 'project1')

@param project_id [String] the project id @param parent_project_id [String] the parent project id @return [Hashie::Mash] of child project details @rest_api_version >= 8.0

# File lib/teamcity/client/projects.rb, line 149
def set_parent_project(project_id, parent_project_id)
  path = "projects/#{project_id}/parentProject"
  payload = { :id => parent_project_id }

  put(path, :content_type => :json, :accept => :json) do |req|
    req.body = payload.to_json
  end
end
set_project_field(project_id, field_name, field_value) click to toggle source

Set a project field

@example Set a projects name

TeamCity.set_project_field('project1', 'name', 'new-name')

@example Set a projects description

TeamCity.set_project_field('project1', 'description', 'new-description')

@example Archive/Unarchive a project

Teamcity.set_project_field('project1', 'archived', 'true|false')

@param project_id [String] the project id @param field_name [String] the field name: 'name', 'description', 'archived' @param field_value [String] the value to set the field to @return [String] project_field_value that was set

# File lib/teamcity/client/projects.rb, line 133
def set_project_field(project_id, field_name, field_value)
  path = "projects/#{project_id}/#{field_name}"
  put(path, :content_type => :text, :accept => :text) do |req|
    req.body = field_value
  end
end
set_project_parameter(project_id, parameter_name, parameter_value) click to toggle source

Set a project parameter (Create or Update)

@param project_id [String] the project id @param parameter_name [String] name of the parameter to set @param parameter_value [String] value of the parameter @return [String] parameter_value that was set

# File lib/teamcity/client/projects.rb, line 113
def set_project_parameter(project_id, parameter_name, parameter_value)
  path = "projects/#{project_id}/parameters/#{parameter_name}"
  put(path, :content_type => :text, :accept => :text) do |req|
    req.body = parameter_value
  end
end