Commit b6adabb45da1413db2c9c6585ff69fa4e40d05fe
Exists in
master
and in
4 other branches
Merge branch '6-1-stable'
Conflicts: lib/tasks/gitlab/check.rake
Showing
5 changed files
with
109 additions
and
2 deletions
Show diff stats
@@ -0,0 +1,59 @@ | @@ -0,0 +1,59 @@ | ||
1 | +# == Schema Information | ||
2 | +# | ||
3 | +# Table name: services | ||
4 | +# | ||
5 | +# id :integer not null, primary key | ||
6 | +# type :string(255) | ||
7 | +# title :string(255) | ||
8 | +# token :string(255) | ||
9 | +# project_id :integer not null | ||
10 | +# created_at :datetime not null | ||
11 | +# updated_at :datetime not null | ||
12 | +# active :boolean default(FALSE), not null | ||
13 | +# | ||
14 | + | ||
15 | +class PivotaltrackerService < Service | ||
16 | + include HTTParty | ||
17 | + | ||
18 | + validates :token, presence: true, if: :activated? | ||
19 | + | ||
20 | + def title | ||
21 | + 'PivotalTracker' | ||
22 | + end | ||
23 | + | ||
24 | + def description | ||
25 | + 'Project Management Software (Source Commits Endpoint)' | ||
26 | + end | ||
27 | + | ||
28 | + def to_param | ||
29 | + 'pivotaltracker' | ||
30 | + end | ||
31 | + | ||
32 | + def fields | ||
33 | + [ | ||
34 | + { type: 'text', name: 'token', placeholder: '' } | ||
35 | + ] | ||
36 | + end | ||
37 | + | ||
38 | + def execute(push) | ||
39 | + url = 'https://www.pivotaltracker.com/services/v5/source_commits' | ||
40 | + push[:commits].each do |commit| | ||
41 | + message = { | ||
42 | + 'source_commit' => { | ||
43 | + 'commit_id' => commit[:id], | ||
44 | + 'author' => commit[:author][:name], | ||
45 | + 'url' => commit[:url], | ||
46 | + 'message' => commit[:message] | ||
47 | + } | ||
48 | + } | ||
49 | + PivotaltrackerService.post( | ||
50 | + url, | ||
51 | + body: message.to_json, | ||
52 | + headers: { | ||
53 | + 'Content-Type' => 'application/json', | ||
54 | + 'X-TrackerToken' => token | ||
55 | + } | ||
56 | + ) | ||
57 | + end | ||
58 | + end | ||
59 | +end |
app/models/project.rb
@@ -46,6 +46,7 @@ class Project < ActiveRecord::Base | @@ -46,6 +46,7 @@ class Project < ActiveRecord::Base | ||
46 | has_one :last_event, class_name: 'Event', order: 'events.created_at DESC', foreign_key: 'project_id' | 46 | has_one :last_event, class_name: 'Event', order: 'events.created_at DESC', foreign_key: 'project_id' |
47 | has_one :gitlab_ci_service, dependent: :destroy | 47 | has_one :gitlab_ci_service, dependent: :destroy |
48 | has_one :campfire_service, dependent: :destroy | 48 | has_one :campfire_service, dependent: :destroy |
49 | + has_one :pivotaltracker_service, dependent: :destroy | ||
49 | has_one :hipchat_service, dependent: :destroy | 50 | has_one :hipchat_service, dependent: :destroy |
50 | has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id" | 51 | has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id" |
51 | has_one :forked_from_project, through: :forked_project_link | 52 | has_one :forked_from_project, through: :forked_project_link |
@@ -220,7 +221,7 @@ class Project < ActiveRecord::Base | @@ -220,7 +221,7 @@ class Project < ActiveRecord::Base | ||
220 | end | 221 | end |
221 | 222 | ||
222 | def available_services_names | 223 | def available_services_names |
223 | - %w(gitlab_ci campfire hipchat) | 224 | + %w(gitlab_ci campfire hipchat pivotaltracker) |
224 | end | 225 | end |
225 | 226 | ||
226 | def gitlab_ci? | 227 | def gitlab_ci? |
features/project/service.feature
@@ -18,3 +18,9 @@ Feature: Project Services | @@ -18,3 +18,9 @@ Feature: Project Services | ||
18 | And I click hipchat service link | 18 | And I click hipchat service link |
19 | And I fill hipchat settings | 19 | And I fill hipchat settings |
20 | Then I should see hipchat service settings saved | 20 | Then I should see hipchat service settings saved |
21 | + | ||
22 | + Scenario: Activate pivotaltracker service | ||
23 | + When I visit project "Shop" services page | ||
24 | + And I click pivotaltracker service link | ||
25 | + And I fill pivotaltracker settings | ||
26 | + Then I should see pivotaltracker service settings saved |
features/steps/project/project_services.rb
@@ -44,4 +44,18 @@ class ProjectServices < Spinach::FeatureSteps | @@ -44,4 +44,18 @@ class ProjectServices < Spinach::FeatureSteps | ||
44 | find_field('Room').value.should == 'gitlab' | 44 | find_field('Room').value.should == 'gitlab' |
45 | end | 45 | end |
46 | 46 | ||
47 | + | ||
48 | + And 'I click pivotaltracker service link' do | ||
49 | + click_link 'PivotalTracker' | ||
50 | + end | ||
51 | + | ||
52 | + And 'I fill pivotaltracker settings' do | ||
53 | + check 'Active' | ||
54 | + fill_in 'Token', with: 'verySecret' | ||
55 | + click_button 'Save' | ||
56 | + end | ||
57 | + | ||
58 | + Then 'I should see pivotaltracker service settings saved' do | ||
59 | + find_field('Token').value.should == 'verySecret' | ||
60 | + end | ||
47 | end | 61 | end |
lib/tasks/gitlab/check.rake
@@ -22,6 +22,7 @@ namespace :gitlab do | @@ -22,6 +22,7 @@ namespace :gitlab do | ||
22 | check_tmp_writable | 22 | check_tmp_writable |
23 | check_init_script_exists | 23 | check_init_script_exists |
24 | check_init_script_up_to_date | 24 | check_init_script_up_to_date |
25 | + check_projects_have_namespace | ||
25 | check_satellites_exist | 26 | check_satellites_exist |
26 | check_redis_version | 27 | check_redis_version |
27 | check_git_version | 28 | check_git_version |
@@ -570,6 +571,32 @@ namespace :gitlab do | @@ -570,6 +571,32 @@ namespace :gitlab do | ||
570 | end | 571 | end |
571 | end | 572 | end |
572 | 573 | ||
574 | + def check_projects_have_namespace | ||
575 | + print "projects have namespace: ... " | ||
576 | + | ||
577 | + unless Project.count > 0 | ||
578 | + puts "can't check, you have no projects".magenta | ||
579 | + return | ||
580 | + end | ||
581 | + puts "" | ||
582 | + | ||
583 | + Project.find_each(batch_size: 100) do |project| | ||
584 | + print "#{project.name_with_namespace.yellow} ... " | ||
585 | + | ||
586 | + if project.namespace | ||
587 | + puts "yes".green | ||
588 | + else | ||
589 | + puts "no".red | ||
590 | + try_fixing_it( | ||
591 | + "Migrate global projects" | ||
592 | + ) | ||
593 | + for_more_information( | ||
594 | + "doc/update/5.4-to-6.0.md in section \"#global-projects\"" | ||
595 | + ) | ||
596 | + fix_and_rerun | ||
597 | + end | ||
598 | + end | ||
599 | + end | ||
573 | 600 | ||
574 | # Helper methods | 601 | # Helper methods |
575 | ######################## | 602 | ######################## |
@@ -677,7 +704,7 @@ namespace :gitlab do | @@ -677,7 +704,7 @@ namespace :gitlab do | ||
677 | end | 704 | end |
678 | 705 | ||
679 | def check_gitlab_shell | 706 | def check_gitlab_shell |
680 | - required_version = Gitlab::VersionInfo.new(1, 7, 0) | 707 | + required_version = Gitlab::VersionInfo.new(1, 7, 1) |
681 | current_version = Gitlab::VersionInfo.parse(gitlab_shell_version) | 708 | current_version = Gitlab::VersionInfo.parse(gitlab_shell_version) |
682 | 709 | ||
683 | print "GitLab Shell version >= #{required_version} ? ... " | 710 | print "GitLab Shell version >= #{required_version} ? ... " |