teamcity 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +19 -0
  3. data/.travis.yml +3 -0
  4. data/.yardopts +1 -0
  5. data/CHANGELOG.md +83 -0
  6. data/Gemfile +4 -0
  7. data/Guardfile +9 -0
  8. data/LICENSE.txt +22 -0
  9. data/README.md +194 -0
  10. data/Rakefile +1 -0
  11. data/lib/faraday/null_response_body.rb +17 -0
  12. data/lib/teamcity.rb +26 -0
  13. data/lib/teamcity/api.rb +19 -0
  14. data/lib/teamcity/client.rb +16 -0
  15. data/lib/teamcity/client/build_types.rb +305 -0
  16. data/lib/teamcity/client/builds.rb +92 -0
  17. data/lib/teamcity/client/common.rb +23 -0
  18. data/lib/teamcity/client/projects.rb +159 -0
  19. data/lib/teamcity/client/tests.rb +24 -0
  20. data/lib/teamcity/client/vcs_roots.rb +70 -0
  21. data/lib/teamcity/configuration.rb +51 -0
  22. data/lib/teamcity/connection.rb +28 -0
  23. data/lib/teamcity/element_builder.rb +27 -0
  24. data/lib/teamcity/headers.rb +47 -0
  25. data/lib/teamcity/request.rb +35 -0
  26. data/lib/teamcity/version.rb +3 -0
  27. data/spec/cassettes/BuildTypes/DELETE/_delete_agent_requirement/should_delete_the_agent_requirement.yml +83 -0
  28. data/spec/cassettes/BuildTypes/DELETE/_delete_buildtype/should_delete_a_buildtype.yml +40 -0
  29. data/spec/cassettes/BuildTypes/DELETE/_delete_buildtype_parameter/should_delete_a_buildtype_parameter.yml +81 -0
  30. data/spec/cassettes/BuildTypes/GET/_buildtype/should_fetch_the_details_of_a_buildtype_by_id.yml +89 -0
  31. data/spec/cassettes/BuildTypes/GET/_buildtype/should_raise_an_error_if_the_buildtype_does_not_exist.yml +52 -0
  32. data/spec/cassettes/BuildTypes/GET/_buildtype_agent_requirements/should_fetch_the_build_configuration_agent_requirements_for_a_buildtype.yml +46 -0
  33. data/spec/cassettes/BuildTypes/GET/_buildtype_agent_requirements/should_return_an_array.yml +46 -0
  34. data/spec/cassettes/BuildTypes/GET/_buildtype_agent_requirements/should_return_nil_if_there_are_no_agent_requirements_defined.yml +46 -0
  35. data/spec/cassettes/BuildTypes/GET/_buildtype_artifact_dependencies/should_fetch_the_build_configuration_artifact_dependencies_for_a_buildtype.yml +46 -0
  36. data/spec/cassettes/BuildTypes/GET/_buildtype_artifact_dependencies/should_return_an_array.yml +46 -0
  37. data/spec/cassettes/BuildTypes/GET/_buildtype_artifact_dependencies/should_return_nil_if_there_are_no_artifact_dependencies_defined.yml +46 -0
  38. data/spec/cassettes/BuildTypes/GET/_buildtype_branches/should_fetch_vcs_branches_the_vcs_root_is_configured_to_use.yml +46 -0
  39. data/spec/cassettes/BuildTypes/GET/_buildtype_features/should_fetch_the_build_configuration_features_for_a_buildtype.yml +46 -0
  40. data/spec/cassettes/BuildTypes/GET/_buildtype_features/should_return_an_array.yml +46 -0
  41. data/spec/cassettes/BuildTypes/GET/_buildtype_features/should_return_nil_if_there_are_no_features_defined.yml +46 -0
  42. data/spec/cassettes/BuildTypes/GET/_buildtype_investigations/should_get_investigation_details.yml +48 -0
  43. data/spec/cassettes/BuildTypes/GET/_buildtype_investigations/should_return_nil_if_no_one_is_investigating.yml +46 -0
  44. data/spec/cassettes/BuildTypes/GET/_buildtype_parameters/should_fetch_the_build_configuration_parameters_for_a_buildtype.yml +46 -0
  45. data/spec/cassettes/BuildTypes/GET/_buildtype_parameters/should_return_an_array.yml +46 -0
  46. data/spec/cassettes/BuildTypes/GET/_buildtype_parameters/should_return_nil_if_there_are_no_parameters_defined.yml +46 -0
  47. data/spec/cassettes/BuildTypes/GET/_buildtype_settings/should_fetch_the_settings_for_a_given_buildtype.yml +89 -0
  48. data/spec/cassettes/BuildTypes/GET/_buildtype_settings/should_return_an_array.yml +89 -0
  49. data/spec/cassettes/BuildTypes/GET/_buildtype_snapshot_dependencies/should_fetch_the_build_configuration_snapshot_dependencies_for_a_buildtype.yml +46 -0
  50. data/spec/cassettes/BuildTypes/GET/_buildtype_snapshot_dependencies/should_return_an_array.yml +46 -0
  51. data/spec/cassettes/BuildTypes/GET/_buildtype_snapshot_dependencies/should_return_nil_if_there_are_no_snapshot_dependencies_defined.yml +46 -0
  52. data/spec/cassettes/BuildTypes/GET/_buildtype_state/should_fetch_the_state_of_the_buildtype.yml +89 -0
  53. data/spec/cassettes/BuildTypes/GET/_buildtype_steps/should_fetch_the_build_configuration_steps_for_a_buildtype.yml +47 -0
  54. data/spec/cassettes/BuildTypes/GET/_buildtype_steps/should_return_an_array.yml +46 -0
  55. data/spec/cassettes/BuildTypes/GET/_buildtype_steps/should_return_nil_if_there_are_no_steps_defined.yml +46 -0
  56. data/spec/cassettes/BuildTypes/GET/_buildtype_template/should_return_nil_if_the_buildtype_is_not_associated_with_a_template.yml +52 -0
  57. data/spec/cassettes/BuildTypes/GET/_buildtype_template/should_return_the_attributes_of_the_associated_template.yml +46 -0
  58. data/spec/cassettes/BuildTypes/GET/_buildtype_triggers/should_fetch_the_build_configuration_triggers_for_a_buildtype.yml +46 -0
  59. data/spec/cassettes/BuildTypes/GET/_buildtype_triggers/should_return_an_array.yml +46 -0
  60. data/spec/cassettes/BuildTypes/GET/_buildtype_triggers/should_return_nil_if_there_are_no_triggers_defined.yml +46 -0
  61. data/spec/cassettes/BuildTypes/GET/_buildtype_vcs_root_entries/should_fetch_the_build_configuration_vcs_root_entries_for_a_buildtype.yml +47 -0
  62. data/spec/cassettes/BuildTypes/GET/_buildtype_vcs_root_entries/should_return_an_array.yml +47 -0
  63. data/spec/cassettes/BuildTypes/GET/_buildtype_vcs_root_entries/should_return_nil_if_there_are_no_vcs_root_entries_defined.yml +46 -0
  64. data/spec/cassettes/BuildTypes/GET/_buildtypes/should_fetch_all_the_buildtypes.yml +46 -0
  65. data/spec/cassettes/BuildTypes/POST/_attach_vcs_root/should_attach_a_vcs_root_to_a_buildtype.yml +47 -0
  66. data/spec/cassettes/BuildTypes/POST/_create_agent_requirement/should_create_an_agent_requirement_for_a_buildtype.yml +46 -0
  67. data/spec/cassettes/BuildTypes/POST/_create_build_step/should_create_a_build_step_for_a_given_build_type.yml +46 -0
  68. data/spec/cassettes/BuildTypes/POST/_create_build_trigger/should_create_a_build_trigger_for_a_given_build_type.yml +46 -0
  69. data/spec/cassettes/BuildTypes/POST/_create_buildtype/should_create_a_build_type.yml +86 -0
  70. data/spec/cassettes/BuildTypes/PUT/_set_build_step_field/should_disable_a_build_step.yml +44 -0
  71. data/spec/cassettes/BuildTypes/PUT/_set_build_step_field/should_enable_a_build_step.yml +48 -0
  72. data/spec/cassettes/BuildTypes/PUT/_set_buildtype_field/should_pause_a_project.yml +44 -0
  73. data/spec/cassettes/BuildTypes/PUT/_set_buildtype_field/should_set_a_projects_description.yml +44 -0
  74. data/spec/cassettes/BuildTypes/PUT/_set_buildtype_field/should_set_the_buildtype_name.yml +44 -0
  75. data/spec/cassettes/BuildTypes/PUT/_set_buildtype_parameter/should_set_a_buildtype_parameter.yml +44 -0
  76. data/spec/cassettes/BuildTypes/PUT/_set_buildtype_setting/should_set_if_it_should_perform_clean_builds.yml +46 -0
  77. data/spec/cassettes/BuildTypes/PUT/_set_buildtype_setting/should_set_what_is_the_timeout_in_minutes_when_executing_builds.yml +46 -0
  78. data/spec/cassettes/BuildTypes/PUT/_set_buildtype_setting/should_set_where_the_checkout_happens_when_building.yml +46 -0
  79. data/spec/cassettes/Builds/DELETE/_unpin_build/should_unpin_a_build.yml +83 -0
  80. data/spec/cassettes/Builds/GET/_build/should_fetch_the_build_details.yml +91 -0
  81. data/spec/cassettes/Builds/GET/_build/should_raise_an_error_if_the_build_does_not_exist.yml +53 -0
  82. data/spec/cassettes/Builds/GET/_build_artifacts/should_fetch_all_the_artifacts.yml +89 -0
  83. data/spec/cassettes/Builds/GET/_build_pinned_/should_return_false_when_a_build_is_not_pinned.yml +126 -0
  84. data/spec/cassettes/Builds/GET/_build_pinned_/should_return_true_when_a_build_is_pinned.yml +126 -0
  85. data/spec/cassettes/Builds/GET/_build_statistics/should_return_statistics_for_a_build.yml +89 -0
  86. data/spec/cassettes/Builds/GET/_build_tags/should_fetch_the_build_tags.yml +89 -0
  87. data/spec/cassettes/Builds/GET/_build_tags/should_return_an_empty_array_if_there_are_no_build_tags_defined_for_a_build.yml +89 -0
  88. data/spec/cassettes/Builds/GET/_builds/should_allow_you_to_filter_by_multiple_build_locators.yml +46 -0
  89. data/spec/cassettes/Builds/GET/_builds/should_allow_you_to_filter_results_by_build_locators.yml +46 -0
  90. data/spec/cassettes/Builds/GET/_builds/should_fetch_all_the_builds.yml +46 -0
  91. data/spec/cassettes/Builds/GET/_builds/should_return_an_empty_array_if_no_results_are_found.yml +46 -0
  92. data/spec/cassettes/Builds/PUT/_pin_build/should_pin_a_build.yml +83 -0
  93. data/spec/cassettes/Projects/DELETE/_delete_project/should_delete_a_project.yml +82 -0
  94. data/spec/cassettes/Projects/DELETE/_delete_project_parameter/should_delete_a_project_parameter.yml +123 -0
  95. data/spec/cassettes/Projects/GET/_parent_project/should_fetch_the_parent_project_for_a_given_project.yml +46 -0
  96. data/spec/cassettes/Projects/GET/_parent_project/should_return_nil_if_there_is_no_parent_project_for_a_given_project.yml +46 -0
  97. data/spec/cassettes/Projects/GET/_project/should_fetch_a_single_project_by_id.yml +47 -0
  98. data/spec/cassettes/Projects/GET/_project/should_raise_an_error_if_the_project_does_not_exist.yml +52 -0
  99. data/spec/cassettes/Projects/GET/_project_buildtypes/should_fetch_all_the_buildTypes_for_a_project.yml +46 -0
  100. data/spec/cassettes/Projects/GET/_project_buildtypes/should_return_nil_if_the_project_does_not_have_any_build_types.yml +46 -0
  101. data/spec/cassettes/Projects/GET/_project_parameters/should_fetch_all_the_paramters_for_a_given_project.yml +46 -0
  102. data/spec/cassettes/Projects/GET/_project_parameters/should_return_nil_if_there_are_no_parameters_defined_for_a_project.yml +46 -0
  103. data/spec/cassettes/Projects/GET/_projects/should_fetch_projects.yml +46 -0
  104. data/spec/cassettes/Projects/POST/_copy_project/should_copy_a_project.yml +135 -0
  105. data/spec/cassettes/Projects/POST/_create_project/should_create_a_project.yml +45 -0
  106. data/spec/cassettes/Projects/PUT/_set_parent_project/should_set_a_parent_project_for_a_given_project.yml +134 -0
  107. data/spec/cassettes/Projects/PUT/_set_project_field/should_archive_a_project.yml +86 -0
  108. data/spec/cassettes/Projects/PUT/_set_project_field/should_set_a_projects_description.yml +86 -0
  109. data/spec/cassettes/Projects/PUT/_set_project_field/should_set_a_projects_name.yml +86 -0
  110. data/spec/cassettes/Projects/PUT/_set_project_parameter/should_set_a_project_parameter.yml +86 -0
  111. data/spec/cassettes/Tests/GET/_tests/should_allow_you_to_filter_by_test_id.yml +49 -0
  112. data/spec/cassettes/Tests/GET/_tests/should_allow_you_to_filter_results_by_test_count_locator.yml +55 -0
  113. data/spec/cassettes/Tests/GET/_tests/should_fetch_all_the_tests.yml +60 -0
  114. data/spec/cassettes/Tests/GET/_tests/should_return_an_empty_array_if_no_build_is_found.yml +51 -0
  115. data/spec/cassettes/Tests/GET/_tests/should_return_an_empty_array_if_no_test_is_found.yml +51 -0
  116. data/spec/cassettes/Tests/GET/_tests/should_return_an_empty_array_if_not_build_is_given.yml +51 -0
  117. data/spec/cassettes/VCSRoots/GET/_vcs_root_details/should_fetch_the_vcs_root_details.yml +91 -0
  118. data/spec/cassettes/VCSRoots/GET/_vcs_roots/should_fetch_vcs_roots.yml +47 -0
  119. data/spec/cassettes/VCSRoots/POST/_create_vcs_root/should_create_a_git_vcs_root_that_is_shared_with_the_project_and_sub-projects.yml +89 -0
  120. data/spec/cassettes/VCSRoots/POST/_create_vcs_root/should_create_a_subversion_vcs_root_that_is_shared_with_the_project_and_sub-projects.yml +89 -0
  121. data/spec/cassettes/VCSRoots/PUT/_set_vcs_root_field/should_set_a_vcs_modification_check_interval.yml +179 -0
  122. data/spec/faraday/null_response_body_spec.rb +18 -0
  123. data/spec/spec_helper.rb +22 -0
  124. data/spec/support/vcr_setup.rb +9 -0
  125. data/spec/teamcity/api_spec.rb +64 -0
  126. data/spec/teamcity/client/builds_spec.rb +113 -0
  127. data/spec/teamcity/client/buildtypes_spec.rb +308 -0
  128. data/spec/teamcity/client/projects_spec.rb +207 -0
  129. data/spec/teamcity/client/tests_spec.rb +47 -0
  130. data/spec/teamcity/client/vcs_roots_spec.rb +86 -0
  131. data/spec/teamcity/client_spec.rb +14 -0
  132. data/spec/teamcity/element_builder_spec.rb +30 -0
  133. data/spec/teamcity/headers_spec.rb +43 -0
  134. data/spec/teamcity/version_spec.rb +7 -0
  135. data/spec/teamcity_spec.rb +89 -0
  136. data/teamcity.gemspec +26 -0
  137. metadata +344 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 3eb6aff20afed3470c00122396362dd62f95df00
4
+ data.tar.gz: b5d2158d34685fb4f82ca754655b83cdfb580f7e
5
+ SHA512:
6
+ metadata.gz: a48358a4caea06e7ab6eb82d8e2dddbec89daa79aa3f363a63852e766b84fb616f8990f42cd0ede01e52ba56015412d7918da5d7775c08b4747b196e76c371f2
7
+ data.tar.gz: 126c66120c7a280b5e09746f0b302aac979e48421f3f443591b1fa3acaec56fe4d2dcea62a8146e06737823746c88b1395c862c63eced9b5fcd530eacb9c5730
data/.gitignore ADDED
@@ -0,0 +1,19 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ .idea
19
+ .ruby-version
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
data/.yardopts ADDED
@@ -0,0 +1 @@
1
+ --tag rest_api_version:"REST API VERSION"
data/CHANGELOG.md ADDED
@@ -0,0 +1,83 @@
1
+ ## 1.3.1 (Jun 4, 20014)
2
+
3
+ * Dependencies
4
+ * Loosen up hashie version constraint to >= 2.0
5
+
6
+ ## 1.3.0 (Jun 4, 2014)
7
+
8
+ * BuildType: Added ```.buildtype_branches```, provides the ability to
9
+ get a listing of branches the build is configured to build.
10
+
11
+ * Dependencies
12
+ * faraday 0.8.5 -> 0.9.0 (fixed some methods to keep consistent return values)
13
+ * hashie 2.0.0 -> 3.0.0
14
+
15
+ * Development
16
+ * Changed .rvmrc file to universal .ruby-version and .ruby-gemset files
17
+
18
+ ## 1.2.0 (Dec 7, 2013)
19
+
20
+ * BuildType: Added ```.set_buildtype_setting```, provides the ability to set build configuration settings [@jeffersongirao]
21
+ * BuildType: Added ```.create_buildtype```, provides the ability to create a new build configuration [@jeffersongirao]
22
+ * BuildType: Added ```.create_build_trigger```, provides the ability to create build configuration trigger [@jeffersongirao], [@nskboy]
23
+ * BuildType: Added ```.set_buildtype_setting```, adds ability to set build configuration settings [@jeffersongirao]
24
+ * BuildType: Added ```.create_build_step```, provides the ability to create a build step in a build configuration [@jeffersongirao]
25
+ * Project: Added ```.set_parent_project``` and ```.parent_project``` for setting and getting parent project. (TeamCity8 only) [@jeffersongirao]
26
+ * Bug: Fix ```.create_vcs_root``` to work for svn [@jeffersongirao]
27
+ * Bug: Fix incompatibility with ruby 1.9.2 [@jeffersongirao]
28
+ * Cleanup: Remove dependency on xmlbuilder and linguistics [@jeffersongirao]
29
+ * Testing: Upgrade to rspec 2.14.1 and added guard-rspec gem
30
+ * Documentation: Added *rest_api_version* tag for specify teamcity api compatibility
31
+
32
+ ## 1.1.0 (Nov 1, 2013)
33
+
34
+ * Features:
35
+ * Added ```build_artifacts``` (Provides the ability to fetch the
36
+ contents of an aritfact) [@orikremer]
37
+
38
+ * Gem Updates
39
+ * Upgraded webmock to remove deprecation warning [@akiellor]
40
+
41
+ ## 1.0.1 (Nov 1, 2013)
42
+
43
+ * Same as 1.1.0 above
44
+
45
+ ## 1.0.0 (Aug 26, 2013)
46
+
47
+ * Features:
48
+ * TeamCity 8 Support
49
+ * Added ```build_pinned?``` (Provides the ability to ask if a build is pinned)
50
+ * If using TeamCity8 any call that is setting a value will now return that value instead of nil
51
+
52
+ * API Changes:
53
+ * ```create_vcs_root``` method signature has been changed from using Ordinal Params to using Hash Params
54
+ * Removed the ability to set the format when configuring the client (Each method will now state what format it is sending and receiving, see the source for more info)
55
+
56
+ * Doc Changes:
57
+ * The API docs were updated to reflect the return values now returned when using TeamCity 8
58
+
59
+ ## 0.4.0 (Jun 15, 2013)
60
+
61
+ * Added ```pin_build``` and ```unpin_build``` (Provides the ability to pin and unpin a build respectively)
62
+ * Added ```build_statistics``` (Provides the ability to fetch build [statistics](http://confluence.jetbrains.com/display/TCD8/Custom+Chart#CustomChart-listOfDefaultStatisticValues))
63
+ * Added ```buildtype_investigations``` (Provides the ability to fetch build investigation details)
64
+
65
+ ## 0.3.0 (May 23, 2013)
66
+
67
+ * Loosen up dependency requirement on the version of builder (Conflicted with transitive dependencies of rails 3.2.13)
68
+ * Added ```delete_buildtype``` to the API (Provides the ability to delete a build configuration)
69
+ * Added ```set_build_step_field``` to the API (Provides the ability to set a build step field, i.e. enable/disable a build step)
70
+
71
+ ## 0.2.0 (May 7, 2013)
72
+
73
+ - added support for httpAuth
74
+ - added several CRUD methods to the api for BuildTypes, Projects, and VCSRoots
75
+ - code cleanup
76
+
77
+ ## 0.1.0 (April 28, 2013)
78
+
79
+ Features:
80
+
81
+ - added GET support for projects
82
+ - added GET support for build types (build configurations)
83
+ - added GET support for builds
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in teamcity-ruby-client.gemspec
4
+ gemspec
data/Guardfile ADDED
@@ -0,0 +1,9 @@
1
+ # A sample Guardfile
2
+ # More info at https://github.com/guard/guard#readme
3
+ #
4
+
5
+ guard :rspec do
6
+ watch(%r{^spec/.+_spec\.rb$})
7
+ watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
8
+ watch('spec/spec_helper.rb') { "spec" }
9
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2013 Jason Perry
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,194 @@
1
+ # The TeamCity Ruby Gem [![Gem Version](https://badge.fury.io/rb/teamcity-ruby-client.png)](http://badge.fury.io/rb/teamcity-ruby-client)
2
+ [![Build Status](https://travis-ci.org/jperry/teamcity-ruby-client.png?branch=master)](https://travis-ci.org/jperry/teamcity-ruby-client.png?branch=master) [![Code Climate](https://codeclimate.com/github/jperry/teamcity-ruby-client.png)](https://codeclimate.com/github/jperry/teamcity-ruby-client) [![Dependency Status](https://gemnasium.com/jperry/teamcity-ruby-client.png)](https://gemnasium.com/jperry/teamcity-ruby-client)
3
+
4
+ Ruby wrapper for the TeamCity Rest API
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'teamcity-ruby-client'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install teamcity-ruby-client
19
+
20
+ ## API Usage Examples
21
+
22
+ * Tested on TeamCity 7.X and 8.0.X
23
+ * Most of the api calls return either an array of Hashie::Mash objects or a single Hashie::Mash object which allows you to send messages to retreive an attribute easily.
24
+ * See [api docs](http://rubydoc.info/gems/teamcity-ruby-client/TeamCity/Client) or [specs](spec/teamcity/client) for additional examples and usage
25
+
26
+ ### Configuration
27
+
28
+ * See [configuration](lib/teamcity/configuration.rb) source or api doc for more configuration options
29
+ * You may use v7 of the TeamCity api by adding '7.0' to the endpoint configuration (This would be similar to using latest on a TeamCity 7 server)
30
+
31
+ ```ruby
32
+ require 'teamcity'
33
+
34
+ # This only needs to be set once per Ruby execution.
35
+ # You may use guestAuth instead of httpAuth and omit the use of http_user and http_password
36
+ # This is using the latest version of the api
37
+ TeamCity.configure do |config|
38
+ config.endpoint = 'http://my-teamcity-server:8111/httpAuth/app/rest'
39
+ config.http_user = 'teamcity-user'
40
+ config.http_password = 'teamcity-password'
41
+ end
42
+ ```
43
+
44
+ ### Projects
45
+
46
+ ```ruby
47
+ # Get a list of projects
48
+ puts TeamCity.projects
49
+
50
+ # Get a project by id
51
+ puts TeamCity.project(id: 'project1')
52
+
53
+ # Get a list of buildtypes for a project
54
+ puts TeamCity.project_buildtypes(id: 'project1')
55
+
56
+ # Each item returned is a Hashie::Mash object which allows you to send messages
57
+ # to retreive an attribute easily. For example, get the name of
58
+ # the first buildtype in a project
59
+ puts TeamCity.project_buildtypes(id: 'project1').first.name
60
+
61
+ # Create an empty project
62
+ TeamCity.create_project('my-new-project')
63
+
64
+ # Copy a project
65
+ TeamCity.copy_project('project1', 'copied-project-name')
66
+
67
+ # Delete a project
68
+ TeamCity.delete_project('project1')
69
+
70
+ # Change project name
71
+ TeamCity.set_project_field('project1', 'name', 'new-project-name')
72
+ ```
73
+
74
+ ### Build Types (Build Configurations)
75
+
76
+ ```ruby
77
+ # Get a list of buildtypes (build configurations)
78
+ puts TeamCity.buildtypes
79
+
80
+ # Get buildtype details (build configuration)
81
+ puts TeamCity.buildtype(id: 'bt1')
82
+
83
+ # Get buildtype steps
84
+ puts TeamCity.buildtype_steps(id: 'bt1')
85
+
86
+ # Change buildtype name
87
+ TeamCity.set_buildtype_field('bt1', 'name', 'new-buildtype-name')
88
+ ```
89
+
90
+ ### Builds ###
91
+
92
+ ```ruby
93
+ # Get build details
94
+ puts TeamCity.build(id: 1)
95
+
96
+ # Get build tags
97
+ puts TeamCity.build_tags(id: 1)
98
+
99
+ # Fetch all the builds (defaults to the last 100 builds, use the 'count' build locator to return more)
100
+ puts TeamCity.builds
101
+
102
+ # Filter builds by multiple criteria's using the build locator
103
+ puts TeamCity.builds(count: 1, status: 'SUCCESS') # This will return the most recent build that passed
104
+
105
+ puts TeamCity.builds(count: 1).first.name
106
+
107
+ puts TeamCity.builds(buildType: 'bt3') # Fetch all builds where buildType=bt4
108
+
109
+ puts TeamCity.builds(status: 'FAILURE') # Fetch all builds that failed
110
+
111
+ # Passing the output to another to fetch additional information
112
+ puts TeamCity.build(id: TeamCity.builds(count: 1).first.id).buildType.name # Fetch the name of the last build to run
113
+
114
+ ```
115
+
116
+ ### VCS Roots ###
117
+
118
+ ```ruby
119
+ # Get all the vcs roots
120
+ puts Teamcity.vcs_roots
121
+
122
+ # Get vcs root details
123
+ puts TeamCity.vcs_root_details(1)
124
+
125
+ # Create VCS Root for a project
126
+ TeamCity.create_vcs_root(vcs_name: 'my-git-vcs-root', vcs_type: 'git', :project_id => 'project2') do |properties|
127
+ properties['branch'] = 'master'
128
+ properties['url'] = 'git@github.com:jperry/teamcity-ruby-client.git'
129
+ properties['authMethod'] = 'PRIVATE_KEY_DEFAULT'
130
+ properties['ignoreKnownHosts'] = true
131
+ end
132
+
133
+ ```
134
+
135
+ ## Documentation
136
+
137
+ ### API Docs
138
+
139
+ [Latest](http://rubydoc.info/gems/teamcity-ruby-client/)
140
+
141
+ ### Generating API Docs
142
+
143
+ 1. Pull the source down
144
+ 2. ```bundle install```
145
+ 3. ```rake yard```
146
+ 4. open doc/index.html
147
+
148
+ ### TeamCity Rest API Plugin
149
+
150
+ [Link](http://confluence.jetbrains.com/display/TW/REST+API+Plugin)
151
+
152
+ ## Contributing
153
+
154
+ Ways to contribute:
155
+
156
+ * report a bug
157
+ * fix an issue that is logged
158
+ * suggest enhancements
159
+ * suggest a new feature
160
+ * cleaning up code
161
+ * refactoring code
162
+ * fix documentation errors
163
+ * test on a new versions of teamcity
164
+ * Use the gem :)
165
+
166
+ ## Submitting an issue
167
+
168
+ I use issue tracker to track bugs, features, enhancements, etc. Please check the list of issues to confirm
169
+ it hasn't already been reported. Please tag the the issue with an appropriate tag. If submitting a bug please
170
+ include any output that will help me in diagnosing the issue, link to a gist if you have multiple outputs
171
+ (client output, teamcity server output). Please include the version of teamcity you are using
172
+ the client against as well as the gem and ruby versions.
173
+
174
+ ## Submitting a Pull Request
175
+
176
+ 1. Fork the project.
177
+ 2. Create a topic branch.
178
+ 3. Implement your feature or bug fix.
179
+ 4. Add documentation for your feature or bug fix.
180
+ * Please use the *@rest_api_version* tag to specify if a method is only compatible with a specific version of the rest api
181
+ 5. Run ```rake doc:yard```. If your changes are not 100% documented, go back to step 4.
182
+ 6. Add specs for your feature or bug fix.
183
+ 7. If the rspec test is making a request use VCR to record the response, see the other examples.
184
+ 7. Run ```rake spec```. If your changes are not 100% covered, go back to step 6.
185
+ 8. Commit and push your changes.
186
+ 9. Submit a pull request.
187
+
188
+ ## Debugging Tips
189
+
190
+ * Enable debug-rest in TeamCity to see all the rest api requests come through in the `teamcity-rest.log`, you can find this on the Diagnostics page under Server Administration
191
+
192
+ ## Questions/Comments
193
+
194
+ Feel free to contact me directly through github. Enjoy!
data/Rakefile ADDED
@@ -0,0 +1 @@
1
+ require 'bundler/gem_tasks'
@@ -0,0 +1,17 @@
1
+ module FaradayMiddleware
2
+ # This middleware handles any responses where the body
3
+ # is 'null' which is the case when asking teamcity for
4
+ # an empty collection. When this is encountered we
5
+ # set the response to an empty json object
6
+ class NullResponseBody < Faraday::Middleware
7
+ # Faraday Middleware
8
+ # @note - should only be called by Faraday
9
+ def call(env)
10
+ @app.call(env).on_complete do |response|
11
+ if response[:body] == "null"
12
+ response[:body] = {}
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
data/lib/teamcity.rb ADDED
@@ -0,0 +1,26 @@
1
+ require_relative 'teamcity/configuration'
2
+ require_relative 'teamcity/client'
3
+ require_relative 'teamcity/headers'
4
+ require_relative 'teamcity/element_builder'
5
+
6
+ module TeamCity
7
+ extend Configuration
8
+
9
+ # Alias for TeamCity::Client.new
10
+ #
11
+ # @return [TeamCity::Client]
12
+ def self.client(options={})
13
+ TeamCity::Client.new(options)
14
+ end
15
+
16
+ # Delegate to TeamCity::Client
17
+ def self.method_missing(method, *args, &block)
18
+ return super unless client.respond_to?(method)
19
+ client.send(method, *args, &block)
20
+ end
21
+
22
+ # Delegate to TeamCity::Client
23
+ def self.respond_to?(method)
24
+ return client.respond_to?(method) || super
25
+ end
26
+ end
@@ -0,0 +1,19 @@
1
+ require_relative 'connection'
2
+ require_relative 'request'
3
+
4
+ module TeamCity
5
+ class API
6
+ attr_accessor *Configuration::VALID_OPTIONS_KEYS
7
+
8
+ # Creates a new API
9
+ def initialize(options={})
10
+ options = TeamCity.options.merge(options)
11
+ Configuration::VALID_OPTIONS_KEYS.each do |key|
12
+ send("#{key}=", options[key])
13
+ end
14
+ end
15
+
16
+ include Connection
17
+ include Request
18
+ end
19
+ end
@@ -0,0 +1,16 @@
1
+ require_relative 'api'
2
+
3
+ module TeamCity
4
+ # Wrapper for the TeamCity REST API
5
+ #
6
+ class Client < API
7
+ Dir[File.expand_path('../client/*.rb', __FILE__)].each{|f| require f}
8
+
9
+ include TeamCity::Client::Projects
10
+ include TeamCity::Client::BuildTypes
11
+ include TeamCity::Client::Builds
12
+ include TeamCity::Client::Common
13
+ include TeamCity::Client::VCSRoots
14
+ include TeamCity::Client::Tests
15
+ end
16
+ end