summaryrefslogtreecommitdiff
path: root/app/models
diff options
context:
space:
mode:
authorKamil Trzcinski <ayufan@ayufan.eu>2016-11-04 16:35:22 +0100
committerAnnabel Dunstone Gray <annabel.dunstone@gmail.com>2016-11-08 16:50:03 -0600
commitc70acb57f5adcd4f0a19f8e7d5bcb356464a9c64 (patch)
tree42d3d2c4d8cfabb29c3144ff2a17591dc5f16d2b /app/models
parent73467bd1634898632d1c9c4e5879546ec9f53032 (diff)
downloadgitlab-ce-c70acb57f5adcd4f0a19f8e7d5bcb356464a9c64.tar.gz
Expose `last_deployment` on `Ci::Builds` [ci skip]
Diffstat (limited to 'app/models')
-rw-r--r--app/models/ci/build.rb10
1 files changed, 7 insertions, 3 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 1b37c70ee4f..09bbea1c653 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -7,6 +7,8 @@ module Ci
belongs_to :trigger_request
belongs_to :erased_by, class_name: 'User'
+ has_many :deployments, as: :deployable
+
serialize :options
serialize :yaml_variables
@@ -125,10 +127,12 @@ module Ci
!self.pipeline.statuses.latest.include?(self)
end
- def last_deployment
- return @last_deployment if defined?(@last_deployment)
+ def deployable?
+ self.environment.present?
+ end
- @last_deployment = Deployment.where(deployable: self).order(id: :desc).last
+ def last_deployment
+ deployments.order(id: :desc).last
end
def depends_on_builds