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
0
Merge Requests
0
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
Tatuya Kamada
gitlab-ce
Commits
406a0c80
Commit
406a0c80
authored
Nov 19, 2012
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GitLabCi Service imtegration
parent
85007434
Changes
16
Show whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
158 additions
and
7 deletions
+158
-7
app/assets/images/service-disabled-gitlab-ci.png
app/assets/images/service-disabled-gitlab-ci.png
+0
-0
app/assets/images/service-gitlab-ci.png
app/assets/images/service-gitlab-ci.png
+0
-0
app/assets/stylesheets/gitlab_bootstrap/common.scss
app/assets/stylesheets/gitlab_bootstrap/common.scss
+3
-0
app/controllers/services_controller.rb
app/controllers/services_controller.rb
+37
-0
app/models/gitlab_ci_service.rb
app/models/gitlab_ci_service.rb
+29
-0
app/models/project.rb
app/models/project.rb
+1
-0
app/models/service.rb
app/models/service.rb
+1
-1
app/roles/push_observer.rb
app/roles/push_observer.rb
+2
-2
app/views/projects/_project_head.html.haml
app/views/projects/_project_head.html.haml
+4
-0
app/views/services/_gitlab_ci.html.haml
app/views/services/_gitlab_ci.html.haml
+42
-0
app/views/services/edit.html.haml
app/views/services/edit.html.haml
+2
-0
app/views/services/index.html.haml
app/views/services/index.html.haml
+15
-0
config/routes.rb
config/routes.rb
+6
-0
db/migrate/20121120103700_add_active_to_service.rb
db/migrate/20121120103700_add_active_to_service.rb
+5
-0
db/migrate/20121120113838_add_project_url_to_service.rb
db/migrate/20121120113838_add_project_url_to_service.rb
+5
-0
db/schema.rb
db/schema.rb
+6
-4
No files found.
app/assets/images/service-disabled-gitlab-ci.png
0 → 100644
View file @
406a0c80
2.13 KB
app/assets/images/service-gitlab-ci.png
View replaced file @
85007434
View file @
406a0c80
2.69 KB
|
W:
|
H:
2.34 KB
|
W:
|
H:
2-up
Swipe
Onion skin
app/assets/stylesheets/gitlab_bootstrap/common.scss
View file @
406a0c80
...
...
@@ -73,6 +73,7 @@ img.avatar.s16 { width:16px; height:16px; margin-right:6px; }
img
.avatar.s24
{
width
:
24px
;
height
:
24px
;
margin-right
:
8px
;
}
img
.avatar.s32
{
width
:
32px
;
height
:
32px
;
margin-right
:
10px
;
}
img
.lil_av
{
padding-left
:
4px
;
padding-right
:
3px
;
}
img
.small
{
width
:
80px
;
}
/** HELPERS **/
.nothing_here_message
{
text-align
:center
;
padding
:
20px
;
color
:
#777
;
}
...
...
@@ -87,3 +88,5 @@ input[type='search'].search-text-input {
@include
border-radius
(
4px
);
border
:
1px
solid
#ccc
;
}
fieldset
legend
{
font-size
:
17px
;
}
app/controllers/services_controller.rb
0 → 100644
View file @
406a0c80
class
ServicesController
<
ProjectResourceController
# Authorize
before_filter
:authorize_admin_project!
respond_to
:html
def
index
@gitlab_ci_service
=
@project
.
gitlab_ci_service
end
def
edit
@service
=
@project
.
gitlab_ci_service
# Create if missing
@service
=
@project
.
create_gitlab_ci_service
unless
@service
end
def
update
@service
=
@project
.
gitlab_ci_service
if
@service
.
update_attributes
(
params
[
:service
])
redirect_to
:back
else
render
'edit'
end
end
def
test
commits
=
project
.
commits
(
project
.
default_branch
,
nil
,
3
)
data
=
project
.
post_receive_data
(
commits
.
last
.
id
,
commits
.
first
.
id
,
"refs/heads/
#{
project
.
default_branch
}
"
,
current_user
)
@service
=
project
.
gitlab_ci_service
@service
.
execute
(
data
)
redirect_to
:back
end
end
app/models/gitlab_ci_service.rb
0 → 100644
View file @
406a0c80
# == 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 not null
# updated_at :datetime not null
#
class
GitlabCiService
<
Service
attr_accessible
:project_url
validates
:project_url
,
presence:
true
validates
:token
,
presence:
true
delegate
:execute
,
to: :service_hook
,
prefix:
nil
after_save
:compose_service_hook
def
compose_service_hook
hook
=
service_hook
||
build_service_hook
hook
.
url
=
[
project_url
,
"/build"
,
"?token=
#{
token
}
"
].
join
(
""
)
hook
.
save
end
end
app/models/project.rb
View file @
406a0c80
...
...
@@ -48,6 +48,7 @@ class Project < ActiveRecord::Base
has_many
:protected_branches
,
dependent: :destroy
has_one
:last_event
,
class_name:
'Event'
,
order:
'events.created_at DESC'
,
foreign_key:
'project_id'
has_many
:services
,
dependent: :destroy
has_one
:gitlab_ci_service
,
dependent: :destroy
delegate
:name
,
to: :owner
,
allow_nil:
true
,
prefix:
true
...
...
app/models/service.rb
View file @
406a0c80
...
...
@@ -12,7 +12,7 @@
#
class
Service
<
ActiveRecord
::
Base
attr_accessible
:title
,
:token
,
:type
attr_accessible
:title
,
:token
,
:type
,
:active
belongs_to
:project
has_one
:service_hook
...
...
app/roles/push_observer.rb
View file @
406a0c80
...
...
@@ -56,8 +56,8 @@ module PushObserver
def
execute_services
(
data
)
services
.
each
do
|
service
|
# Call service hook
for service if it has on
e
service
.
service_hook
.
execute
if
service
.
service_hook
# Call service hook
only if it is activ
e
service
.
execute
if
service
.
active
end
end
...
...
app/views/projects/_project_head.html.haml
View file @
406a0c80
...
...
@@ -21,6 +21,10 @@
=
link_to
project_hooks_path
(
@project
)
do
%span
Hooks
=
nav_link
(
controller: :services
,
html_options:
{
class:
'right'
})
do
=
link_to
project_services_path
(
@project
)
do
%span
Services
=
nav_link
(
path:
'projects#edit'
,
html_options:
{
class:
'right'
})
do
=
link_to
edit_project_path
(
@project
),
class:
"stat-tab tab "
do
%i
.icon-edit
...
...
app/views/services/_gitlab_ci.html.haml
0 → 100644
View file @
406a0c80
%h3
.page_title
Services
→
GitLab CI Integration
.right
.thumbnail
-
if
@service
.
active
=
image_tag
'service-gitlab-ci.png'
,
class:
'small'
-
else
=
image_tag
'service-disabled-gitlab-ci.png'
,
class:
'small'
%hr
=
form_for
(
@service
,
:as
=>
:service
,
:url
=>
project_service_path
(
@project
,
@service
),
:method
=>
:put
)
do
|
f
|
-
if
@service
.
errors
.
any?
.alert-message.block-message.error
%ul
-
@service
.
errors
.
full_messages
.
each
do
|
msg
|
%li
=
msg
.control-group
=
f
.
label
:active
,
"Active"
,
class:
"control-label"
.controls
=
f
.
check_box
:active
.control-group
=
f
.
label
:active
,
"Project URL"
,
class:
"control-label"
.controls
=
f
.
text_field
:project_url
,
class:
"input-xlarge"
,
placeholder:
"http://ci.gitlabhq.com/projects/3"
.control-group
=
f
.
label
:token
,
class:
"control-label"
do
CI Project token
.controls
=
f
.
text_field
:token
,
class:
"input-xlarge"
,
placeholder:
"GitLab CI project specific token"
.form-actions
=
f
.
submit
'Save'
,
class:
'btn save-btn'
=
link_to
'Test settings'
,
test_project_service_path
(
@project
),
class:
'btn btn-small'
app/views/services/edit.html.haml
0 → 100644
View file @
406a0c80
=
render
"projects/project_head"
=
render
'gitlab_ci'
app/views/services/index.html.haml
0 → 100644
View file @
406a0c80
=
render
"projects/project_head"
%h3
.page_title
Services
%hr
.row
.span6
.padded
%p
.slead
Continuous integration server from GitLab
.thumbnail.left
=
link_to
edit_project_service_path
(
@project
,
:gitlab_ci
)
do
-
if
@gitlab_ci_service
.
try
:active
=
image_tag
'service-gitlab-ci.png'
-
else
=
image_tag
'service-disabled-gitlab-ci.png'
config/routes.rb
View file @
406a0c80
...
...
@@ -133,6 +133,12 @@ Gitlab::Application.routes.draw do
end
end
resources
:services
,
constraints:
{
id:
/[^\/]+/
},
only:
[
:index
,
:edit
,
:update
]
do
member
do
get
:test
end
end
resources
:deploy_keys
resources
:protected_branches
,
only:
[
:index
,
:create
,
:destroy
]
...
...
db/migrate/20121120103700_add_active_to_service.rb
0 → 100644
View file @
406a0c80
class
AddActiveToService
<
ActiveRecord
::
Migration
def
change
add_column
:services
,
:active
,
:boolean
,
default:
false
,
null:
false
end
end
db/migrate/20121120113838_add_project_url_to_service.rb
0 → 100644
View file @
406a0c80
class
AddProjectUrlToService
<
ActiveRecord
::
Migration
def
change
add_column
:services
,
:project_url
,
:string
,
null:
true
end
end
db/schema.rb
View file @
406a0c80
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
20121120
051432
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
20121120
113838
)
do
create_table
"events"
,
:force
=>
true
do
|
t
|
t
.
string
"target_type"
...
...
@@ -134,6 +134,8 @@ ActiveRecord::Schema.define(:version => 20121120051432) do
t
.
integer
"project_id"
,
:null
=>
false
t
.
datetime
"created_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
t
.
boolean
"active"
,
:default
=>
false
,
:null
=>
false
t
.
string
"project_url"
end
create_table
"snippets"
,
:force
=>
true
do
|
t
|
...
...
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