summaryrefslogtreecommitdiff
path: root/app/models/project.rb
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/project.rb
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/project.rb')
-rw-r--r--app/models/project.rb19
1 files changed, 19 insertions, 0 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