sambot 0.1.212 → 0.1.213

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d50132a71162661d13b1ed378127edf1e58fa099
4
- data.tar.gz: ebd3d955a88ad71015706814e4e9e846c1813c6b
3
+ metadata.gz: c9b0b31feb12f1eec5396f1a2791a54d9babbf9c
4
+ data.tar.gz: 71dd1d30db522ec8ef0e49ac69352cf0e10d66de
5
5
  SHA512:
6
- metadata.gz: dbef3dfd7a84847112f1f5e254f22e1f7a77b8cec223570525140635634f18d51f7315551c89edac2d471378ca008e81a82d3a0f439dc583343e583dfab8364f
7
- data.tar.gz: 3283faefd74d4953b6cb7bcf7cbbd7f2f74042b33e775c2ac8c5be860c1bc054e8b4ad040e18f98c8f144442ad22ccce568db42dc7d97f704d5dd876cd74451d
6
+ metadata.gz: d2eaef4a93835ce8c4194a7611628375428578b83455b68ca3a4cd971b5f4cf25af5e75dc879723d9bc7892eb032b9f572c2baf611f084ccfee00dd6a2765061
7
+ data.tar.gz: 7eb99d5c944baa51653bfe8ccff70cd1efc8f50c36a6dfae150cda1e702d67c638471e29fc4ca98989ba40c7b135fe8453619e9921e910494fbc47da7f74018f
data/lib/sambot.rb CHANGED
@@ -1,6 +1,9 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'thor'
4
+ require 'teamcity'
5
+ require 'awesome_print'
6
+ require 'pry'
4
7
 
5
8
  require_relative 'sambot/application_error'
6
9
  require_relative 'sambot/config'
@@ -10,6 +13,7 @@ require_relative 'sambot/version'
10
13
  require_relative 'sambot/template'
11
14
  require_relative 'sambot/fs'
12
15
  require_relative 'sambot/source_control'
16
+ require_relative 'sambot/team_city'
13
17
 
14
18
  require_relative 'sambot/testing/consul_helper'
15
19
  require_relative 'sambot/testing/vault_helper'
@@ -27,5 +31,9 @@ require_relative 'sambot/tasks/create'
27
31
 
28
32
  require_relative 'sambot/cli'
29
33
 
34
+ require_relative 'sambot/teamcity/faraday'
35
+ require_relative 'sambot/teamcity/projects'
36
+ require_relative 'sambot/teamcity/builds'
37
+
30
38
  module Sambot
31
39
  end
@@ -0,0 +1,37 @@
1
+ module TeamCity
2
+ class Client
3
+ module Builds
4
+
5
+ def attach_template(build_id, template_id)
6
+ path = "buildTypes/#{build_id}/template"
7
+ put(path, :content_type => :text) do |request|
8
+ request.body = template_id
9
+ end
10
+ end
11
+
12
+ def create_build(project_id, name)
13
+ path = "projects/#{project_id}/buildTypes"
14
+ payload = { name: name }
15
+ post(path, :content_type => :json, :accept => :json) do |request|
16
+ request.body = payload.to_json
17
+ end
18
+ end
19
+
20
+ def create_cookbook_build(config)
21
+ ::TeamCity.configure do |config|
22
+ config.endpoint = 'https://teamcity.brighter.io/httpAuth/app/rest' || ENV['TEAMCITY_URL']
23
+ config.http_user = ENV['TEAMCITY_USERNAME']
24
+ config.http_password = ENV['TEAMCITY_PASSWORD']
25
+ end
26
+ # Identify which projects this cookbook belongs to (ROLE OR WRAPPER)
27
+ # Create a build configuration for it
28
+ project = ::TeamCity.find_project_by_name(LINUX_ROLES_PROJECT_NAME)
29
+ template = ::TeamCity.project_templates(id: project.id)[0]
30
+ build_configuration = ::TeamCity.create_build(project.id, name)
31
+ ::TeamCity.attach_template(build_configuration.id, template.id)
32
+ ::TeamCity.delete_buildtype(build_configuration.id)
33
+ end
34
+
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,26 @@
1
+ module TeamCity
2
+ module Connection
3
+
4
+ private
5
+
6
+ def connection(options={})
7
+
8
+ faraday_options = {
9
+ :headers => {
10
+ 'User-Agent' => user_agent
11
+ }.merge((headers = Headers.build(options)).to_hash),
12
+ :ssl => {:verify => false},
13
+ :url => endpoint
14
+ }
15
+ Faraday::Connection.new(faraday_options) do |connection|
16
+ connection.use Faraday::Request::UrlEncoded
17
+ connection.use FaradayMiddleware::Mashify
18
+ connection.use FaradayMiddleware::ParseJson if headers.accept =~ /json/
19
+ connection.use FaradayMiddleware::NullResponseBody
20
+ connection.use Faraday::Response::Logger
21
+ connection.adapter(adapter)
22
+ connection.basic_auth(http_user, http_password)
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,21 @@
1
+ module TeamCity
2
+ class Client
3
+
4
+ module Projects
5
+
6
+ def find_project_by_name(name)
7
+ projects = ::TeamCity.projects
8
+ projects.find { |project| project.name.match(name) }
9
+ end
10
+
11
+ def project_templates(options)
12
+ assert_options(options)
13
+ request = "projects/#{locator(options)}/templates"
14
+ response = get(request)
15
+ response['buildType']
16
+ end
17
+
18
+ end
19
+
20
+ end
21
+ end
@@ -9,28 +9,16 @@ chef exec berks update
9
9
  chef exec rspec spec --col
10
10
  set +e
11
11
 
12
- <% if ENV['TEST_KITCHEN_ACTION'] == 'converge' %>
13
- chef exec kitchen converge <%= ENV['TEST_KITCHEN_PLATFORM'] || '' %> -l <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
14
- <% elsif ENV['TEST_KITCHEN_ACTION'] == 'create' %>
15
- chef exec kitchen create <%= ENV['TEST_KITCHEN_PLATFORM'] || '' %> -l <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
16
- <% elsif ENV['TEST_KITCHEN_ACTION'] == 'multi-step-test' %>
17
- chef exec kitchen converge <%= ENV['TEST_KITCHEN_PLATFORM'] || '' %> -l <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
18
- chef exec kitchen verify <%= ENV['TEST_KITCHEN_PLATFORM'] || '' %> -l <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
19
- chef exec kitchen destroy <%= ENV['TEST_KITCHEN_PLATFORM'] || '' %> -l <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
20
- <% else %>
21
- <% unless ENV['SKIP_TESTING_AS_EMERGENCY'] %>
22
- chef exec kitchen create <%= ENV['TEST_KITCHEN_PLATFORM'] || '' %> -l <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
23
- sleep 45
24
- chef exec kitchen verify <%= ENV['TEST_KITCHEN_PLATFORM'] || '' %> -l <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
25
- RETVAL=$?
26
- if [ $RETVAL -eq 0 ] ; then
27
- chef exec kitchen destroy <%= ENV['TEST_KITCHEN_PLATFORM'] || '' %> -l <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
28
- echo "Test Kitchen converged and all tests passed - Ready to upload to server"
29
- exit $RETVAL
30
- elif [ $RETVAL -ne 0 ] ; then
31
- echo "Test Kitchen failed - cleaning up"
32
- kitchen destroy <%= ENV['TEST_KITCHEN_PLATFORM'] || '' %> -l <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
33
- exit $RETVAL
34
- fi
35
- <% end %>
36
- <% end %>
12
+ chef exec kitchen create -l <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
13
+ sleep 45
14
+ chef exec kitchen verify -l <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
15
+ RETVAL=$?
16
+ if [ $RETVAL -eq 0 ] ; then
17
+ chef exec kitchen destroy -l <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
18
+ echo "Test Kitchen converged and all tests passed - Ready to upload to server"
19
+ exit $RETVAL
20
+ elif [ $RETVAL -ne 0 ] ; then
21
+ echo "Test Kitchen failed - cleaning up"
22
+ kitchen destroy -l <%= ENV['TEST_KITCHEN_LOG_LEVEL'] || 'info' %>
23
+ exit $RETVAL
24
+ fi
@@ -24,7 +24,7 @@ platforms:
24
24
  preemptible: true
25
25
  service_account_name: <%= ENV['GCP_SERVICE_ACCOUNT_NAME'] %>
26
26
  custom_metadata_from_disk:
27
- startup-script: <%= ENV['GCP_BOOTSTRAP_SCRIPT_CENTOS'] %>
27
+ startup-script: bootstrap.sh
28
28
  service_account_scopes:
29
29
  - userinfo-email
30
30
  - logging-write
@@ -54,7 +54,7 @@ platforms:
54
54
  disk_size: 80
55
55
  service_account_name: <%= ENV['GCP_SERVICE_ACCOUNT_NAME'] %>
56
56
  custom_metadata_from_disk:
57
- windows-startup-script: <%= ENV['GCP_BOOTSTRAP_SCRIPT_WINDOWS'] %>
57
+ windows-startup-script: bootstrap.ps1
58
58
  service_account_scopes:
59
59
  - userinfo-email
60
60
  - logging-write
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Sambot
4
- VERSION = '0.1.212'
4
+ VERSION = '0.1.213'
5
5
  end
data/sambot.gemspec CHANGED
@@ -27,6 +27,7 @@ Gem::Specification.new do |spec|
27
27
  spec.add_dependency 'vault'
28
28
  spec.add_dependency 'ridley'
29
29
  spec.add_dependency 'titan'
30
+ spec.add_dependency 'teamcity-ruby-client'
30
31
  spec.add_dependency 'open4'
31
32
  spec.add_dependency 'diplomat'
32
33
  spec.add_dependency 'semantic'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sambot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.212
4
+ version: 0.1.213
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olivier Kouame
@@ -122,6 +122,20 @@ dependencies:
122
122
  - - ">="
123
123
  - !ruby/object:Gem::Version
124
124
  version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: teamcity-ruby-client
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '0'
132
+ type: :runtime
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
125
139
  - !ruby/object:Gem::Dependency
126
140
  name: open4
127
141
  requirement: !ruby/object:Gem::Requirement
@@ -403,6 +417,9 @@ files:
403
417
  - lib/sambot/source_control.rb
404
418
  - lib/sambot/tasks/create.rb
405
419
  - lib/sambot/team_city.rb
420
+ - lib/sambot/teamcity/builds.rb
421
+ - lib/sambot/teamcity/faraday.rb
422
+ - lib/sambot/teamcity/projects.rb
406
423
  - lib/sambot/template.rb
407
424
  - lib/sambot/templates/.config.yml.erb
408
425
  - lib/sambot/templates/.env