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
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
...
...
app/views/projects/builds/show.html.haml
View file @
c70acb57
...
...
@@ -26,28 +26,30 @@
=
link_to
namespace_project_runners_path
(
@build
.
project
.
namespace
,
@build
.
project
)
do
Runners page
-
if
@build
.
deploy
-
if
@build
.
deploy
able?
.prepend-top-default
.environment-information
=
ci_icon_for_status
(
@build
.
status
)
-
if
@build
.
last_deployment
This build is the most recent deployment to
=
link_to
@build
.
environment
,
namespace_project_environment_path
(
@project
.
namespace
,
@project
,
@build
.
environment
)
-
else
-
case
@build
.
status
-
when
'failed'
,
'canceled'
-
last_deployment
=
@build
.
last_deployment
-
if
@build
.
complete?
-
if
@build
.
success?
-
if
last_deployment
.
try
(
:last?
)
This build is the most recent deployment to
=
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
=
link_to
@build
.
environment
,
namespace_project_environment_path
(
@project
.
namespace
,
@project
,
@build
.
environment
)
=
environment_link_for_build
(
@build
.
project
,
@build
)
did not complete
-
when
'pending'
,
'running'
This build is creating a deployment to
=
link_to
@build
.
environment
,
namespace_project_environment_path
(
@project
.
namespace
,
@project
,
@build
.
environment
)
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
-
else
This build is creating a deployment to
=
environment_link_for_build
(
@build
.
project
,
@build
)
and will overwrite the latest deployment
.prepend-top-default
-
if
@build
.
erased?
...
...
app/workers/build_success_worker.rb
View file @
c70acb57
...
...
@@ -4,15 +4,13 @@ class BuildSuccessWorker
def
perform
(
build_id
)
Ci
::
Build
.
find_by
(
id:
build_id
).
try
do
|
build
|
create_deployment
(
build
)
create_deployment
(
build
)
if
build
.
deployable?
end
end
private
def
create_deployment
(
build
)
return
if
build
.
environment
.
blank?
service
=
CreateDeploymentService
.
new
(
build
.
project
,
build
.
user
,
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