Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
c70acb57
Commit
c70acb57
authored
Nov 04, 2016
by
Kamil Trzcinski
Committed by
Annabel Dunstone Gray
Nov 08, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose `last_deployment` on `Ci::Builds` [ci skip]
parent
73467bd1
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
47 additions
and
22 deletions
+47
-22
app/helpers/environment_helper.rb
app/helpers/environment_helper.rb
+21
-0
app/models/ci/build.rb
app/models/ci/build.rb
+7
-3
app/views/projects/builds/show.html.haml
app/views/projects/builds/show.html.haml
+18
-16
app/workers/build_success_worker.rb
app/workers/build_success_worker.rb
+1
-3
No files found.
app/helpers/environment_helper.rb
0 → 100644
View file @
c70acb57
module
EnvironmentHelper
def
environment_for_build
(
project
,
build
)
return
unless
build
.
environment
environment_name
=
ExpandVariables
.
expand
(
build
.
environment
,
build
.
variables
)
project
.
environments
.
find_by
(
name:
environment_name
)
end
def
environment_link_for_build
(
project
,
build
)
environment
=
environment_for_build
(
project
,
build
)
return
unless
environment
link_to
environment
.
name
,
namespace_project_environment_path
(
project
.
namespace
,
project
,
environment
)
end
def
deployment_link
(
project
,
deployment
)
return
unless
deployment
link_to
"#
#{
deployment
.
id
}
"
,
[
deployment
.
project
.
namespace
.
becomes
(
Namespace
),
deployment
.
project
,
deployment
.
deployable
]
end
end
app/models/ci/build.rb
View file @
c70acb57
...
@@ -7,6 +7,8 @@ module Ci
...
@@ -7,6 +7,8 @@ module Ci
belongs_to
:trigger_request
belongs_to
:trigger_request
belongs_to
:erased_by
,
class_name:
'User'
belongs_to
:erased_by
,
class_name:
'User'
has_many
:deployments
,
as: :deployable
serialize
:options
serialize
:options
serialize
:yaml_variables
serialize
:yaml_variables
...
@@ -125,10 +127,12 @@ module Ci
...
@@ -125,10 +127,12 @@ module Ci
!
self
.
pipeline
.
statuses
.
latest
.
include?
(
self
)
!
self
.
pipeline
.
statuses
.
latest
.
include?
(
self
)
end
end
def
last_deployment
def
deployable?
return
@last_deployment
if
defined?
(
@last_deployment
)
self
.
environment
.
present?
end
@last_deployment
=
Deployment
.
where
(
deployable:
self
).
order
(
id: :desc
).
last
def
last_deployment
deployments
.
order
(
id: :desc
).
last
end
end
def
depends_on_builds
def
depends_on_builds
...
...
app/views/projects/builds/show.html.haml
View file @
c70acb57
...
@@ -26,28 +26,30 @@
...
@@ -26,28 +26,30 @@
=
link_to
namespace_project_runners_path
(
@build
.
project
.
namespace
,
@build
.
project
)
do
=
link_to
namespace_project_runners_path
(
@build
.
project
.
namespace
,
@build
.
project
)
do
Runners page
Runners page
-
if
@build
.
deploy
-
if
@build
.
deploy
able?
.prepend-top-default
.prepend-top-default
.environment-information
.environment-information
=
ci_icon_for_status
(
@build
.
status
)
=
ci_icon_for_status
(
@build
.
status
)
-
if
@build
.
last_deployment
-
last_deployment
=
@build
.
last_deployment
This build is the most recent deployment to
-
if
@build
.
complete?
=
link_to
@build
.
environment
,
namespace_project_environment_path
(
@project
.
namespace
,
@project
,
@build
.
environment
)
-
if
@build
.
success?
-
else
-
if
last_deployment
.
try
(
:last?
)
-
case
@build
.
status
This build is the most recent deployment to
-
when
'failed'
,
'canceled'
=
environment_link_for_build
(
@build
.
project
,
@build
)
-
else
This build is an out-of-date deployment to
=
environment_link_for_build
(
@build
.
project
,
@build
)
View the most recent deployment
=
deployment_link
(
@project
,
last_deployment
)
-
else
The deployment of this build to
The deployment of this build to
=
link_to
@build
.
environment
,
namespace_project_environment_path
(
@project
.
namespace
,
@project
,
@build
.
environment
)
=
environment_link_for_build
(
@build
.
project
,
@build
)
did not complete
did not complete
-
when
'pending'
,
'running'
-
else
This build is creating a deployment to
This build is creating a deployment to
=
link_to
@build
.
environment
,
namespace_project_environment_path
(
@project
.
namespace
,
@project
,
@build
.
environment
)
=
environment_link_for_build
(
@build
.
project
,
@build
)
and will overwrite the latest deployment
and will overwrite the latest deployment
-
when
'success'
This build is an out-of-date deployment to
=
link_to
@build
.
environment
,
namespace_project_environment_path
(
@project
.
namespace
,
@project
,
@build
.
environment
)
View the most recent deployment #24869
.prepend-top-default
.prepend-top-default
-
if
@build
.
erased?
-
if
@build
.
erased?
...
...
app/workers/build_success_worker.rb
View file @
c70acb57
...
@@ -4,15 +4,13 @@ class BuildSuccessWorker
...
@@ -4,15 +4,13 @@ class BuildSuccessWorker
def
perform
(
build_id
)
def
perform
(
build_id
)
Ci
::
Build
.
find_by
(
id:
build_id
).
try
do
|
build
|
Ci
::
Build
.
find_by
(
id:
build_id
).
try
do
|
build
|
create_deployment
(
build
)
create_deployment
(
build
)
if
build
.
deployable?
end
end
end
end
private
private
def
create_deployment
(
build
)
def
create_deployment
(
build
)
return
if
build
.
environment
.
blank?
service
=
CreateDeploymentService
.
new
(
service
=
CreateDeploymentService
.
new
(
build
.
project
,
build
.
user
,
build
.
project
,
build
.
user
,
environment:
build
.
environment
,
environment:
build
.
environment
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment