Module: TeamCity::Client::VCSRoots

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

Constant Summary collapse

VCS_TYPES =
{ 'git' => 'jetbrains.git' }

Instance Method Summary collapse

Instance Method Details

#create_vcs_root(options = {}) {|Hash| ... } ⇒ Hashie::Mash

Create VCS Root

Examples:

Create a Git VCS Root that pulls from master that is only shared with it's project and sub-projecdts and uses the default private key

TeamCity.create_vcs_root(:vcs_name => 'my-git-vcs-root', :vcs_type => 'git', :project_id => 'project2') do |properties|
  properties['branch'] = 'master'
  properties['url'] = '[email protected]:jperry/teamcity-ruby-client.git'
  properties['authMethod'] = 'PRIVATE_KEY_DEFAULT'
  properties['ignoreKnownHosts'] = true
end

Options Hash (options):

  • :vcs_name (String)

    Name of the vcs root

  • :vcs_type (String)

    Type of VCS: 'git', 'perforce', etc

  • :project_id (String)

    to create the vcs root under

Yields:

  • (Hash)

    properties to set on the vcs root, view the page source of the vcs root page for the id and value of a property


38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/teamcity/client/vcs_roots.rb', line 38

def create_vcs_root(options = {}, &block)
  attributes = {
    :name    => options.fetch(:vcs_name),
    :vcsName => VCS_TYPES[options.fetch(:vcs_type)] || options.fetch(:vcs_type),
    :projectLocator => options.fetch(:project_id)
  }

  builder = TeamCity::ElementBuilder.new(attributes, &block)

  post("vcs-roots", :content_type => :json) do |req|
    req.body = builder.to_request_body
  end
end

#vcs_root_details(vcs_root_id) ⇒ Hashie::Mash

Get VCS Root details


19
20
21
# File 'lib/teamcity/client/vcs_roots.rb', line 19

def vcs_root_details(vcs_root_id)
  get("vcs-roots/id:#{vcs_root_id}")
end

#vcs_rootsArray<Hashie::Mash>?

List of VCS Roots


10
11
12
13
# File 'lib/teamcity/client/vcs_roots.rb', line 10

def vcs_roots
  response = get('vcs-roots')
  response['vcs-root']
end