summaryrefslogtreecommitdiff
path: root/app/models/ci/build.rb
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2016-11-18 15:49:19 +0000
committerFatih Acet <acetfatih@gmail.com>2016-11-18 15:49:19 +0000
commit1e8cb595bf2fc84c85198cf8dc43d16e587c57df (patch)
tree55b8133e3054d9a35691209da71551c360a357c1 /app/models/ci/build.rb
parentc55733bc5058b793389101cce47b9b5807d73fd0 (diff)
parent9ed7171a6a8c98858949891b298789a97c4f3fba (diff)
downloadgitlab-ce-1e8cb595bf2fc84c85198cf8dc43d16e587c57df.tar.gz
Merge branch '23205-information-about-environments-build-page' into 'master'
Add environment info to builds page ![Screen_Shot_2016-11-02_at_5.44.01_PM](/uploads/3443d9518997147d1e6f41830e3774ff/Screen_Shot_2016-11-02_at_5.44.01_PM.png) Closes #23205 See merge request !7251
Diffstat (limited to 'app/models/ci/build.rb')
-rw-r--r--app/models/ci/build.rb30
1 files changed, 30 insertions, 0 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 33612256540..5d2e7d94190 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,6 +127,34 @@ module Ci
!self.pipeline.statuses.latest.include?(self)
end
+ def expanded_environment_name
+ ExpandVariables.expand(environment, variables) if environment
+ end
+
+ def has_environment?
+ self.environment.present?
+ end
+
+ def starts_environment?
+ has_environment? && self.environment_action == 'start'
+ end
+
+ def stops_environment?
+ has_environment? && self.environment_action == 'stop'
+ end
+
+ def environment_action
+ self.options.fetch(:environment, {}).fetch(:action, 'start')
+ end
+
+ def outdated_deployment?
+ success? && !last_deployment.try(:last?)
+ end
+
+ def last_deployment
+ deployments.last
+ end
+
def depends_on_builds
# Get builds of the same type
latest_builds = self.pipeline.builds.latest