module TeamCity::Client::Builds
Constants
- GCP_PROJECT
- LINUX_ROLE_COOKBOOKS_PROJECT
- LINUX_WRAPPER_COOKBOOKS_PROJECT
Public Instance Methods
attach_template(build_id, template_id)
click to toggle source
# File lib/sambot/teamcity/builds.rb, line 9 def attach_template(build_id, template_id) path = "buildTypes/#{build_id}/template" put(path, :content_type => :text) do |request| request.body = template_id end end
build_exists?(project, build_name)
click to toggle source
# File lib/sambot/teamcity/builds.rb, line 24 def build_exists?(project, build_name) all_builds = TeamCity.project_buildtypes(id: project.id).map {|x| x.name} all_builds.include?(build_name) end
create_build(project_id, name)
click to toggle source
# File lib/sambot/teamcity/builds.rb, line 16 def create_build(project_id, name) path = "projects/#{project_id}/buildTypes" payload = { name: name } post(path, :content_type => :json, :accept => :json) do |request| request.body = payload.to_json end end
create_cookbook_build(config)
click to toggle source
# File lib/sambot/teamcity/builds.rb, line 29 def create_cookbook_build(config) ::TeamCity.configure do |config| config.endpoint = 'https://teamcity.brighter.io/httpAuth/app/rest' || ENV['TEAMCITY_URL'] config.http_user = ENV['TEAMCITY_USERNAME'] config.http_password = ENV['TEAMCITY_PASSWORD'] end project_name = config.is_role_cookbook? ? LINUX_ROLE_COOKBOOKS_PROJECT : LINUX_WRAPPER_COOKBOOKS_PROJECT ::Sambot::UI.debug("Looking for the project #{project_name}") project = ::TeamCity.find_project_by_name(project_name) if build_exists?(project, config.name) ::Sambot::UI.info("The build configuration '#{config.name}' already exists in the project '#{project.name}'") else ::Sambot::UI.debug("Looking for the template project #{GCP_PROJECT}") template_project = ::TeamCity.find_project_by_name(GCP_PROJECT) template = ::TeamCity.project_templates(id: template_project.id)[0] ::Sambot::UI.debug("Using the TeamCity template #{template.name}") build_configuration = ::TeamCity.create_build(project.id, config.name) ::TeamCity.attach_template(build_configuration.id, template.id) ::Sambot::UI.info("The build configuration '#{config.name}' has been created in the project '#{project.name}'") build_configuration end end