Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
80f9b758
Commit
80f9b758
authored
Oct 08, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' of github.com:gitlabhq/gitlabhq
parents
17835f09
e1123e08
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
213 additions
and
7 deletions
+213
-7
app/models/project.rb
app/models/project.rb
+2
-1
app/models/project_services/buildbox_service.rb
app/models/project_services/buildbox_service.rb
+121
-0
app/views/projects/show.html.haml
app/views/projects/show.html.haml
+8
-5
lib/tasks/gitlab/import.rake
lib/tasks/gitlab/import.rake
+4
-1
spec/models/buildbox_service_spec.rb
spec/models/buildbox_service_spec.rb
+78
-0
No files found.
app/models/project.rb
View file @
80f9b758
...
...
@@ -64,6 +64,7 @@ class Project < ActiveRecord::Base
has_one
:assembla_service
,
dependent: :destroy
has_one
:gemnasium_service
,
dependent: :destroy
has_one
:slack_service
,
dependent: :destroy
has_one
:buildbox_service
,
dependent: :destroy
has_one
:pushover_service
,
dependent: :destroy
has_one
:forked_project_link
,
dependent: :destroy
,
foreign_key:
"forked_to_project_id"
has_one
:forked_from_project
,
through: :forked_project_link
...
...
@@ -312,7 +313,7 @@ class Project < ActiveRecord::Base
end
def
available_services_names
%w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push gemnasium slack pushover)
%w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push gemnasium slack pushover
buildbox
)
end
def
gitlab_ci?
...
...
app/models/project_services/buildbox_service.rb
0 → 100644
View file @
80f9b758
# == Schema Information
#
# Table name: services
#
# id :integer not null, primary key
# type :string(255)
# title :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# property :text
#
class
BuildboxService
<
CiService
prop_accessor
:project_url
,
:token
validates
:project_url
,
presence:
true
,
if: :activated?
validates
:token
,
presence:
true
,
if: :activated?
after_save
:compose_service_hook
,
if: :activated?
def
webhook_url
"
#{
buildbox_endpoint
(
'webhook'
)
}
/deliver/
#{
webhook_token
}
"
end
def
compose_service_hook
hook
=
service_hook
||
build_service_hook
hook
.
url
=
webhook_url
hook
.
save
end
def
execute
(
data
)
service_hook
.
execute
(
data
)
end
def
commit_status
(
sha
)
response
=
HTTParty
.
get
(
commit_status_path
(
sha
),
verify:
false
)
if
response
.
code
==
200
&&
response
[
'status'
]
response
[
'status'
]
else
:error
end
end
def
commit_status_path
(
sha
)
"
#{
buildbox_endpoint
(
'gitlab'
)
}
/status/
#{
status_token
}
.json?commit=
#{
sha
}
"
end
def
build_page
(
sha
)
"
#{
project_url
}
/builds?commit=
#{
sha
}
"
end
def
builds_path
"
#{
project_url
}
/builds?branch=
#{
project
.
default_branch
}
"
end
def
status_img_path
"
#{
buildbox_endpoint
(
'badge'
)
}
/
#{
status_token
}
.svg"
end
def
title
'Buildbox'
end
def
description
'Continuous integration and deployments'
end
def
to_param
'buildbox'
end
def
fields
[
{
type:
'text'
,
name:
'token'
,
placeholder:
'Buildbox project GitLab token'
},
{
type:
'text'
,
name:
'project_url'
,
placeholder:
'https://buildbox.io/example/project'
}
]
end
private
def
webhook_token
token_parts
.
first
end
def
status_token
token_parts
.
second
end
def
token_parts
if
token
.
present?
token
.
split
(
':'
)
else
[]
end
end
def
buildbox_endpoint
(
subdomain
=
nil
)
endpoint
=
'https://buildbox.io'
if
subdomain
.
present?
uri
=
Addressable
::
URI
.
parse
(
endpoint
)
new_endpoint
=
"
#{
uri
.
scheme
||
'http'
}
://
#{
subdomain
}
.
#{
uri
.
host
}
"
if
uri
.
port
.
present?
"
#{
new_endpoint
}
:
#{
uri
.
port
}
"
else
new_endpoint
end
else
endpoint
end
end
end
app/views/projects/show.html.haml
View file @
80f9b758
...
...
@@ -62,11 +62,14 @@
-
else
#{
link_to
@project
.
owner_name
,
@project
.
owner
}
-
if
@project
.
gitlab_ci?
%hr
=
link_to
@project
.
gitlab_ci_service
.
builds_path
do
=
image_tag
@project
.
gitlab_ci_service
.
status_img_path
,
alt:
"build status"
-
@project
.
ci_services
.
each
do
|
ci_service
|
-
if
ci_service
.
active?
&&
ci_service
.
respond_to?
(
:builds_path
)
-
if
ci_service
.
respond_to?
(
:status_img_path
)
=
link_to
ci_service
.
builds_path
do
=
image_tag
ci_service
.
status_img_path
,
alt:
"build status"
-
else
%span
.light
CI provided by
=
link_to
ci_service
.
title
,
ci_service
.
builds_path
-
if
readme
.tab-pane
#tab-readme
...
...
lib/tasks/gitlab/import.rake
View file @
80f9b758
...
...
@@ -27,7 +27,10 @@ namespace :gitlab do
group_name
=
nil
if
group_name
==
'.'
# Skip if group or user
next
if
namespaces
.
include?
(
name
)
if
namespaces
.
include?
(
name
)
puts
"Skipping
#{
project
.
name
}
due to namespace conflict with group or user"
.
yellow
next
end
puts
"Processing
#{
repo_path
}
"
.
yellow
...
...
spec/models/buildbox_service_spec.rb
0 → 100644
View file @
80f9b758
# == Schema Information
#
# Table name: services
#
# id :integer not null, primary key
# type :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# project_url :string(255)
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
#
require
'spec_helper'
describe
BuildboxService
do
describe
'Associations'
do
it
{
should
belong_to
:project
}
it
{
should
have_one
:service_hook
}
end
describe
'commits methods'
do
before
do
@project
=
Project
.
new
@project
.
stub
(
default_branch:
'default-brancho'
)
@service
=
BuildboxService
.
new
@service
.
stub
(
project:
@project
,
service_hook:
true
,
project_url:
'https://buildbox.io/account-name/example-project'
,
token:
'secret-sauce-webhook-token:secret-sauce-status-token'
)
end
describe
:webhook_url
do
it
'returns the webhook url'
do
@service
.
webhook_url
.
should
==
'https://webhook.buildbox.io/deliver/secret-sauce-webhook-token'
end
end
describe
:commit_status_path
do
it
'returns the correct status page'
do
@service
.
commit_status_path
(
'2ab7834c'
).
should
==
'https://gitlab.buildbox.io/status/secret-sauce-status-token.json?commit=2ab7834c'
end
end
describe
:build_page
do
it
'returns the correct build page'
do
@service
.
build_page
(
'2ab7834c'
).
should
==
'https://buildbox.io/account-name/example-project/builds?commit=2ab7834c'
end
end
describe
:builds_page
do
it
'returns the correct path to the builds page'
do
@service
.
builds_path
.
should
==
'https://buildbox.io/account-name/example-project/builds?branch=default-brancho'
end
end
describe
:status_img_path
do
it
'returns the correct path to the status image'
do
@service
.
status_img_path
.
should
==
'https://badge.buildbox.io/secret-sauce-status-token.svg'
end
end
end
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment