Commit ba0f5b7a authored by Juanito Fatas's avatar Juanito Fatas

Update Buildkite service

Buildkite supports push, merge_request, and tag_push events

Update pipeline‘s description

Add a test for enable_ssl_verification

Add changelog for Update Buildkite Service
parent f840c12e
......@@ -15,6 +15,10 @@ class BuildkiteService < CiService
after_save :compose_service_hook, if: :activated?
def self.supported_events
%w(push merge_request tag_push)
end
def webhook_url
"#{buildkite_endpoint('webhook')}/deliver/#{webhook_token}"
end
......@@ -22,7 +26,7 @@ class BuildkiteService < CiService
def compose_service_hook
hook = service_hook || build_service_hook
hook.url = webhook_url
hook.enable_ssl_verification = !!enable_ssl_verification
hook.enable_ssl_verification = true
hook.save
end
......@@ -49,7 +53,7 @@ class BuildkiteService < CiService
end
def description
'Continuous integration and deployments'
'Buildkite is a platform for running fast, secure, and scalable continuous integration pipelines on your own infrastructure'
end
def self.to_param
......@@ -60,15 +64,15 @@ class BuildkiteService < CiService
[
{ type: 'text',
name: 'token',
placeholder: 'Buildkite project GitLab token', required: true },
title: 'Integration Token',
help: 'This token will be provided when you create a Buildkite pipeline with a GitLab repository',
required: true },
{ type: 'text',
name: 'project_url',
placeholder: "#{ENDPOINT}/example/project", required: true },
{ type: 'checkbox',
name: 'enable_ssl_verification',
title: "Enable SSL verification" }
title: 'Pipeline URL',
placeholder: "#{ENDPOINT}/acme-inc/test-pipeline",
required: true }
]
end
......
---
title: "Update Buildkite Service for supported events, fields, and always verify SSL"
merge_request: 33697
author: "Juanito Fatas"
type: changed
......@@ -247,13 +247,7 @@ module API
required: true,
name: :project_url,
type: String,
desc: 'The buildkite project URL'
},
{
required: false,
name: :enable_ssl_verification,
type: Boolean,
desc: 'Enable SSL verification for communication'
desc: 'The Buildkite pipeline URL'
}
],
'campfire' => [
......
......@@ -82,7 +82,7 @@ RSpec.describe Projects::ServicesController do
'active' => '1',
'push_events' => '1',
'token' => 'token',
'project_url' => 'http://test.com'
'project_url' => 'https://buildkite.com/organization/pipeline'
}
end
......
......@@ -13,7 +13,7 @@ RSpec.describe BuildkiteService, :use_clean_rails_memory_store_caching do
project: project,
properties: {
service_hook: true,
project_url: 'https://buildkite.com/account-name/example-project',
project_url: 'https://buildkite.com/organization-name/example-pipeline',
token: 'secret-sauce-webhook-token:secret-sauce-status-token'
}
)
......@@ -45,11 +45,26 @@ RSpec.describe BuildkiteService, :use_clean_rails_memory_store_caching do
end
end
describe '.supported_events' do
it 'supports push, merge_request, and tag_push events' do
expect(service.supported_events).to eq %w(push merge_request tag_push)
end
end
describe 'commits methods' do
before do
allow(project).to receive(:default_branch).and_return('default-brancho')
end
it 'always activates SSL verification after saved' do
service.enable_ssl_verification = false
service.active = true
service.save!
expect(service.reload.enable_ssl_verification).to be true
end
describe '#webhook_url' do
it 'returns the webhook url' do
expect(service.webhook_url).to eq(
......@@ -69,7 +84,7 @@ RSpec.describe BuildkiteService, :use_clean_rails_memory_store_caching do
describe '#build_page' do
it 'returns the correct build page' do
expect(service.build_page('2ab7834c', nil)).to eq(
'https://buildkite.com/account-name/example-project/builds?commit=2ab7834c'
'https://buildkite.com/organization-name/example-pipeline/builds?commit=2ab7834c'
)
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment