summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorLin Jen-Shin <godfat@godfat.org>2016-07-19 21:24:40 +0800
committerLin Jen-Shin <godfat@godfat.org>2016-07-19 21:24:40 +0800
commit87604ed6ceb7d088dd4ebbc20185fe6ef46180c5 (patch)
treef856fdec8195f1484453b9d86d9947fb43d4cf58 /app
parent08b9532e376eae369cd04d9f86ea560acfd19ed0 (diff)
parente57c0c89f082e98f0fa0f3bd5ab0778c7304c41e (diff)
downloadgitlab-ce-87604ed6ceb7d088dd4ebbc20185fe6ef46180c5.tar.gz
Merge branch 'master' into artifacts-from-ref-and-build-name-api
* master: (23 commits) Add CHANGELOG entry [ci skip] CHANGELOG item Added redirect_to_referer to login link on issues Simplify entities for branches and tags API Added Rake task for tracking deployments Return the number of marked todos Use local_assigns Use `humanize` Improve code design Remove unused create_pipeline_service_spec.rb Add notice implementation Make manual actions to work with master code Use `capitalize` instead of `titleize` for manual actions Mark builds with manual actions as skipped Fix rubocop offenses Update build fixtures to include manual actions Improve manual actions code and add model, service and feature tests Rename playable_actions to manual_actions Add implementation of manual actions Position commit icons closer to branch name/tag/sha; add min-width to pipeline actions cell ...
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/pages/pipelines.scss50
-rw-r--r--app/controllers/projects/builds_controller.rb13
-rw-r--r--app/models/ci/build.rb24
-rw-r--r--app/models/ci/pipeline.rb4
-rw-r--r--app/models/commit_status.rb4
-rw-r--r--app/models/concerns/statuseable.rb6
-rw-r--r--app/models/deployment.rb4
-rw-r--r--app/services/ci/create_builds_service.rb6
-rw-r--r--app/views/projects/ci/builds/_build.html.haml13
-rw-r--r--app/views/projects/ci/pipelines/_pipeline.html.haml46
-rw-r--r--app/views/projects/deployments/_actions.haml22
-rw-r--r--app/views/projects/deployments/_deployment.html.haml10
-rw-r--r--app/views/projects/environments/_environment.html.haml3
-rw-r--r--app/views/projects/environments/index.html.haml1
-rw-r--r--app/views/projects/environments/show.html.haml2
-rw-r--r--app/views/projects/notes/_notes_with_form.html.haml4
16 files changed, 160 insertions, 52 deletions
diff --git a/app/assets/stylesheets/pages/pipelines.scss b/app/assets/stylesheets/pages/pipelines.scss
index a0334207c68..a3b72ec9574 100644
--- a/app/assets/stylesheets/pages/pipelines.scss
+++ b/app/assets/stylesheets/pages/pipelines.scss
@@ -1,7 +1,7 @@
.pipelines {
.stage {
- max-width: 80px;
- width: 80px;
+ max-width: 90px;
+ width: 90px;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
@@ -30,13 +30,17 @@
}
.table.builds {
- min-width: 1100px;
+ min-width: 1200px;
tr {
th {
- padding: 16px;
+ padding: 16px 8px;
border: none;
}
+
+ td {
+ padding: 10px 8px;
+ }
}
tbody {
@@ -53,9 +57,8 @@
.branch-commit {
.branch-name {
- margin-left: 8px;
font-weight: bold;
- max-width: 180px;
+ max-width: 150px;
overflow: hidden;
display: inline-block;
white-space: nowrap;
@@ -64,10 +67,15 @@
}
svg {
- margin: 0 6px;
height: 14px;
width: auto;
vertical-align: middle;
+ fill: $table-text-gray;
+ }
+
+ .fa {
+ font-size: 12px;
+ color: $table-text-gray;
}
.commit-id {
@@ -100,6 +108,22 @@
}
}
+ .icon-container {
+ display: inline-block;
+ text-align: right;
+ width: 20px;
+
+ .fa {
+ position: relative;
+ right: 3px;
+ }
+
+ svg {
+ position: relative;
+ right: 1px;
+ }
+ }
+
.duration,
.finished-at {
color: $table-text-gray;
@@ -107,21 +131,19 @@
.fa {
font-size: 12px;
+ margin-right: 4px;
}
svg {
- height: 12px;
- width: auto;
+ width: 12px;
+ height: auto;
vertical-align: middle;
- }
-
- .fa,
- svg {
- margin-right: 5px;
+ margin-right: 4px;
}
}
.pipeline-actions {
+ min-width: 140px;
.btn {
margin: 0;
diff --git a/app/controllers/projects/builds_controller.rb b/app/controllers/projects/builds_controller.rb
index d7513d75f01..553b62741a5 100644
--- a/app/controllers/projects/builds_controller.rb
+++ b/app/controllers/projects/builds_controller.rb
@@ -1,6 +1,6 @@
class Projects::BuildsController < Projects::ApplicationController
before_action :build, except: [:index, :cancel_all]
- before_action :authorize_read_build!, except: [:cancel, :cancel_all, :retry]
+ before_action :authorize_read_build!, except: [:cancel, :cancel_all, :retry, :play]
before_action :authorize_update_build!, except: [:index, :show, :status, :raw]
layout 'project'
@@ -49,14 +49,19 @@ class Projects::BuildsController < Projects::ApplicationController
end
def retry
- unless @build.retryable?
- return render_404
- end
+ return render_404 unless @build.retryable?
build = Ci::Build.retry(@build, current_user)
redirect_to build_path(build)
end
+ def play
+ return render_404 unless @build.playable?
+
+ build = @build.play(current_user)
+ redirect_to build_path(build)
+ end
+
def cancel
@build.cancel
redirect_to build_path(@build)
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb
index 65dfe4f0190..20492c54729 100644
--- a/app/models/ci/build.rb
+++ b/app/models/ci/build.rb
@@ -18,6 +18,7 @@ module Ci
scope :latest_successful_with_artifacts, ->() do
with_artifacts.success.order(id: :desc)
end
+ scope :manual_actions, ->() { where(when: :manual) }
mount_uploader :artifacts_file, ArtifactUploader
mount_uploader :artifacts_metadata, ArtifactUploader
@@ -94,6 +95,29 @@ module Ci
end
end
+ def manual?
+ self.when == 'manual'
+ end
+
+ def other_actions
+ pipeline.manual_actions.where.not(id: self)
+ end
+
+ def playable?
+ project.builds_enabled? && commands.present? && manual?
+ end
+
+ def play(current_user = nil)
+ # Try to queue a current build
+ if self.queue
+ self.update(user: current_user)
+ self
+ else
+ # Otherwise we need to create a duplicate
+ Ci::Build.retry(self, current_user)
+ end
+ end
+
def retryable?
project.builds_enabled? && commands.present? && complete?
end
diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb
index f5b4124d1ee..fab91bdae5a 100644
--- a/app/models/ci/pipeline.rb
+++ b/app/models/ci/pipeline.rb
@@ -77,6 +77,10 @@ module Ci
!tag?
end
+ def manual_actions
+ builds.latest.manual_actions
+ end
+
def retryable?
builds.latest.any? do |build|
build.failed? && build.retryable?
diff --git a/app/models/commit_status.rb b/app/models/commit_status.rb
index e437e3417a8..535db26240a 100644
--- a/app/models/commit_status.rb
+++ b/app/models/commit_status.rb
@@ -22,6 +22,10 @@ class CommitStatus < ActiveRecord::Base
scope :ignored, -> { where(allow_failure: true, status: [:failed, :canceled]) }
state_machine :status, initial: :pending do
+ event :queue do
+ transition skipped: :pending
+ end
+
event :run do
transition pending: :running
end
diff --git a/app/models/concerns/statuseable.rb b/app/models/concerns/statuseable.rb
index 3ef91caad47..44c6b30f278 100644
--- a/app/models/concerns/statuseable.rb
+++ b/app/models/concerns/statuseable.rb
@@ -16,10 +16,10 @@ module Statuseable
deduce_status = "(CASE
WHEN (#{builds})=0 THEN NULL
- WHEN (#{builds})=(#{success})+(#{ignored}) THEN 'success'
- WHEN (#{builds})=(#{pending}) THEN 'pending'
- WHEN (#{builds})=(#{canceled})+(#{success})+(#{ignored}) THEN 'canceled'
WHEN (#{builds})=(#{skipped}) THEN 'skipped'
+ WHEN (#{builds})=(#{success})+(#{ignored})+(#{skipped}) THEN 'success'
+ WHEN (#{builds})=(#{pending})+(#{skipped}) THEN 'pending'
+ WHEN (#{builds})=(#{canceled})+(#{success})+(#{ignored})+(#{skipped}) THEN 'canceled'
WHEN (#{running})+(#{pending})>0 THEN 'running'
ELSE 'failed'
END)"
diff --git a/app/models/deployment.rb b/app/models/deployment.rb
index 520026c18dd..1a7cd60817e 100644
--- a/app/models/deployment.rb
+++ b/app/models/deployment.rb
@@ -32,4 +32,8 @@ class Deployment < ActiveRecord::Base
def keep_around_commit
project.repository.keep_around(self.sha)
end
+
+ def manual_actions
+ deployable.try(:other_actions)
+ end
end
diff --git a/app/services/ci/create_builds_service.rb b/app/services/ci/create_builds_service.rb
index 3b21f0acb96..4946f7076fd 100644
--- a/app/services/ci/create_builds_service.rb
+++ b/app/services/ci/create_builds_service.rb
@@ -15,7 +15,7 @@ module Ci
status == 'success'
when 'on_failure'
status == 'failed'
- when 'always'
+ when 'always', 'manual'
%w(success failed).include?(status)
end
end
@@ -47,6 +47,10 @@ module Ci
user: user,
project: @pipeline.project)
+ # TODO: The proper implementation for this is in
+ # https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5295
+ build_attrs[:status] = 'skipped' if build_attrs[:when] == 'manual'
+
##
# We do not persist new builds here.
# Those will be persisted when @pipeline is saved.
diff --git a/app/views/projects/ci/builds/_build.html.haml b/app/views/projects/ci/builds/_build.html.haml
index e1b42b2cfa5..9264289987d 100644
--- a/app/views/projects/ci/builds/_build.html.haml
+++ b/app/views/projects/ci/builds/_build.html.haml
@@ -39,6 +39,8 @@
%span.label.label-danger allowed to fail
- if defined?(retried) && retried
%span.label.label-warning retried
+ - if build.manual?
+ %span.label.label-info manual
- if defined?(runner) && runner
@@ -79,6 +81,11 @@
- if build.active?
= link_to cancel_namespace_project_build_path(build.project.namespace, build.project, build, return_to: request.original_url), method: :post, title: 'Cancel', class: 'btn btn-build' do
= icon('remove', class: 'cred')
- - elsif defined?(allow_retry) && allow_retry && build.retryable?
- = link_to retry_namespace_project_build_path(build.project.namespace, build.project, build, return_to: request.original_url), method: :post, title: 'Retry', class: 'btn btn-build' do
- = icon('repeat')
+ - elsif defined?(allow_retry) && allow_retry
+ - if build.retryable?
+ = link_to retry_namespace_project_build_path(build.project.namespace, build.project, build, return_to: request.original_url), method: :post, title: 'Retry', class: 'btn btn-build' do
+ = icon('repeat')
+ - elsif build.playable?
+ = link_to play_namespace_project_build_path(build.project.namespace, build.project, build, return_to: request.original_url), method: :post, title: 'Play', class: 'btn btn-build' do
+ = icon('play')
+
diff --git a/app/views/projects/ci/pipelines/_pipeline.html.haml b/app/views/projects/ci/pipelines/_pipeline.html.haml
index 0557d384e33..996c9073770 100644
--- a/app/views/projects/ci/pipelines/_pipeline.html.haml
+++ b/app/views/projects/ci/pipelines/_pipeline.html.haml
@@ -10,12 +10,13 @@
= link_to namespace_project_pipeline_path(@project.namespace, @project, pipeline.id) do
%span ##{pipeline.id}
- if pipeline.ref
+ .icon-container
+ = pipeline.tag? ? icon('tag') : icon('code-fork')
= link_to pipeline.ref, namespace_project_commits_path(@project.namespace, @project, pipeline.ref), class: "monospace branch-name"
- = custom_icon("icon_commit")
+ .icon-container
+ = custom_icon("icon_commit")
= link_to pipeline.short_sha, namespace_project_commit_path(@project.namespace, @project, pipeline.sha), class: "commit-id monospace"
- - if pipeline.tag?
- %span.label.label-primary tag
- - elsif pipeline.latest?
+ - if pipeline.latest?
%span.label.label-success.has-tooltip{ title: 'Latest build for this branch' } latest
- if pipeline.triggered?
%span.label.label-primary triggered
@@ -57,18 +58,31 @@
%td.pipeline-actions
.controls.hidden-xs.pull-right
- artifacts = pipeline.builds.latest.select { |b| b.artifacts? }
- - if artifacts.present?
- .inline
- .btn-group
- %a.dropdown-toggle.btn.btn-default.build-artifacts{type: 'button', 'data-toggle' => 'dropdown'}
- = icon("download")
- %b.caret
- %ul.dropdown-menu.dropdown-menu-align-right
- - artifacts.each do |build|
- %li
- = link_to download_namespace_project_build_artifacts_path(@project.namespace, @project, build), rel: 'nofollow' do
- = icon("download")
- %span Download '#{build.name}' artifacts
+ - actions = pipeline.manual_actions
+ - if artifacts.present? || actions.any?
+ .btn-group.inline
+ - if actions.any?
+ .btn-group
+ %a.dropdown-toggle.btn.btn-default{type: 'button', 'data-toggle' => 'dropdown'}
+ = icon("play")
+ %b.caret
+ %ul.dropdown-menu.dropdown-menu-align-right
+ - actions.each do |build|
+ %li
+ = link_to play_namespace_project_build_path(@project.namespace, @project, build), method: :post, rel: 'nofollow' do
+ = icon("play")
+ %span= build.name.humanize
+ - if artifacts.present?
+ .btn-group
+ %a.dropdown-toggle.btn.btn-default.build-artifacts{type: 'button', 'data-toggle' => 'dropdown'}
+ = icon("download")
+ %b.caret
+ %ul.dropdown-menu.dropdown-menu-align-right
+ - artifacts.each do |build|
+ %li
+ = link_to download_namespace_project_build_artifacts_path(@project.namespace, @project, build), rel: 'nofollow' do
+ = icon("download")
+ %span Download '#{build.name}' artifacts
- if can?(current_user, :update_pipeline, @project)
.cancel-retry-btns.inline
diff --git a/app/views/projects/deployments/_actions.haml b/app/views/projects/deployments/_actions.haml
new file mode 100644
index 00000000000..65d68aa2985
--- /dev/null
+++ b/app/views/projects/deployments/_actions.haml
@@ -0,0 +1,22 @@
+- if can?(current_user, :create_deployment, deployment) && deployment.deployable
+ .pull-right
+ - actions = deployment.manual_actions
+ - if actions.present?
+ .btn-group.inline
+ .btn-group
+ %a.dropdown-toggle.btn.btn-default{type: 'button', 'data-toggle' => 'dropdown'}
+ = icon("play")
+ %b.caret
+ %ul.dropdown-menu.dropdown-menu-align-right
+ - actions.each do |action|
+ %li
+ = link_to [:play, @project.namespace.becomes(Namespace), @project, action], method: :post, rel: 'nofollow' do
+ = icon("play")
+ %span= action.name.humanize
+
+ - if local_assigns.fetch(:allow_rollback, false)
+ = link_to [:retry, @project.namespace.becomes(Namespace), @project, deployment.deployable], method: :post, class: 'btn btn-build' do
+ - if deployment.last?
+ Retry
+ - else
+ Rollback
diff --git a/app/views/projects/deployments/_deployment.html.haml b/app/views/projects/deployments/_deployment.html.haml
index d08dd92f1f6..baf02f1e6a0 100644
--- a/app/views/projects/deployments/_deployment.html.haml
+++ b/app/views/projects/deployments/_deployment.html.haml
@@ -7,17 +7,11 @@
%td
- if deployment.deployable
- = link_to namespace_project_build_path(@project.namespace, @project, deployment.deployable) do
+ = link_to [@project.namespace.becomes(Namespace), @project, deployment.deployable] do
= "#{deployment.deployable.name} (##{deployment.deployable.id})"
%td
#{time_ago_with_tooltip(deployment.created_at)}
%td
- - if can?(current_user, :create_deployment, deployment) && deployment.deployable
- .pull-right
- = link_to retry_namespace_project_build_path(@project.namespace, @project, deployment.deployable), method: :post, class: 'btn btn-build' do
- - if deployment.last?
- Retry
- - else
- Rollback
+ = render 'projects/deployments/actions', deployment: deployment, allow_rollback: true
diff --git a/app/views/projects/environments/_environment.html.haml b/app/views/projects/environments/_environment.html.haml
index eafa246d05f..e2453395602 100644
--- a/app/views/projects/environments/_environment.html.haml
+++ b/app/views/projects/environments/_environment.html.haml
@@ -15,3 +15,6 @@
%td
- if last_deployment
#{time_ago_with_tooltip(last_deployment.created_at)}
+
+ %td
+ = render 'projects/deployments/actions', deployment: last_deployment
diff --git a/app/views/projects/environments/index.html.haml b/app/views/projects/environments/index.html.haml
index 303d7c23d01..a6dd34653ab 100644
--- a/app/views/projects/environments/index.html.haml
+++ b/app/views/projects/environments/index.html.haml
@@ -28,4 +28,5 @@
%th Environment
%th Last deployment
%th Date
+ %th
= render @environments
diff --git a/app/views/projects/environments/show.html.haml b/app/views/projects/environments/show.html.haml
index b17aba2431f..b8b1ce52a91 100644
--- a/app/views/projects/environments/show.html.haml
+++ b/app/views/projects/environments/show.html.haml
@@ -5,7 +5,7 @@
%div{ class: container_class }
.top-area
.col-md-9
- %h3.page-title= @environment.name.titleize
+ %h3.page-title= @environment.name.capitalize
.col-md-3
.nav-controls
diff --git a/app/views/projects/notes/_notes_with_form.html.haml b/app/views/projects/notes/_notes_with_form.html.haml
index 56d302fab82..74538a9723e 100644
--- a/app/views/projects/notes/_notes_with_form.html.haml
+++ b/app/views/projects/notes/_notes_with_form.html.haml
@@ -14,9 +14,9 @@
.disabled-comment.text-center
.disabled-comment-text.inline
Please
- = link_to "register",new_user_session_path
+ = link_to "register", new_session_path(:user, redirect_to_referer: 'yes')
or
- = link_to "login",new_user_session_path
+ = link_to "login", new_session_path(:user, redirect_to_referer: 'yes')
to post a comment
:javascript