summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-09-23 13:11:40 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-09-23 13:11:40 +0200
commit2eb9a20f36054d99e52342aae1b018206e7791a3 (patch)
tree818c1602c82a63de6c1078d41a02a971e6adb5e0 /app/models
parent3b6915d8910296296676e32129138c50bb1b0c5c (diff)
downloadgitlab-ce-2eb9a20f36054d99e52342aae1b018206e7791a3.tar.gz
Enable CI for gitlab when .gitlab-ci.yml is pushed
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'app/models')
-rw-r--r--app/models/project.rb19
-rw-r--r--app/models/project_services/gitlab_ci_service.rb2
2 files changed, 20 insertions, 1 deletions
diff --git a/app/models/project.rb b/app/models/project.rb
index 72120885105..c5c94cbfba2 100644
--- a/app/models/project.rb
+++ b/app/models/project.rb
@@ -739,4 +739,23 @@ class Project < ActiveRecord::Base
def ci_commit(sha)
gitlab_ci_project.commits.find_by(sha: sha) if gitlab_ci?
end
+
+ def enable_ci(user)
+ # Enable service
+ service = gitlab_ci_service || create_gitlab_ci_service
+ service.active = true
+ service.save
+
+ # Create Ci::Project
+ params = OpenStruct.new({
+ id: self.id,
+ name_with_namespace: self.name_with_namespace,
+ path_with_namespace: self.path_with_namespace,
+ web_url: self.web_url,
+ default_branch: self.default_branch,
+ ssh_url_to_repo: self.ssh_url_to_repo
+ })
+
+ Ci::CreateProjectService.new.execute(user, params)
+ end
end
diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb
index 9e2b3bcd873..ec3bd44024f 100644
--- a/app/models/project_services/gitlab_ci_service.rb
+++ b/app/models/project_services/gitlab_ci_service.rb
@@ -72,7 +72,7 @@ class GitlabCiService < CiService
})
ci_project = Ci::Project.find_by!(gitlab_id: project.id)
-
+
Ci::CreateProjectService.new.execute(
current_user,
params,