Class: Projects::BuildsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/projects/builds_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#redirect_back_or_default

Methods included from PageLayoutHelper

#blank_container, #container_class, #fluid_layout, #header_title, #nav, #page_card_attributes, #page_card_meta_tags, #page_description, #page_image, #page_title, #sidebar

Methods included from GitlabRoutingHelper

#activity_project_path, #edit_project_path, #edit_project_url, #issue_path, #issue_url, #merge_request_path, #merge_request_url, #milestone_path, #project_builds_path, #project_commits_path, #project_files_path, #project_path, #project_pipelines_path, #project_snippet_url, #project_url, #runner_path, #runners_path, #toggle_subscription_path

Methods included from Gitlab::GonHelper

#add_gon_variables

Methods included from Gitlab::CurrentSettings

#current_application_settings, #fake_application_settings

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Projects::ApplicationController

Instance Method Details

#cancelObject


50
51
52
53
# File 'app/controllers/projects/builds_controller.rb', line 50

def cancel
  @build.cancel
  redirect_to build_path(@build)
end

#cancel_allObject


23
24
25
26
# File 'app/controllers/projects/builds_controller.rb', line 23

def cancel_all
  @project.builds.running_or_pending.each(&:cancel)
  redirect_to namespace_project_builds_path(project.namespace, project)
end

#eraseObject


59
60
61
62
63
# File 'app/controllers/projects/builds_controller.rb', line 59

def erase
  @build.erase(erased_by: current_user)
  redirect_to namespace_project_build_path(project.namespace, project, @build),
              notice: "Build has been sucessfully erased!"
end

#indexObject


7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/projects/builds_controller.rb', line 7

def index
  @scope = params[:scope]
  @all_builds = project.builds
  @builds = @all_builds.order('created_at DESC')
  @builds =
    case @scope
    when 'running'
      @builds.running_or_pending.reverse_order
    when 'finished'
      @builds.finished
    else
      @builds
    end
  @builds = @builds.page(params[:page]).per(30)
end

#rawObject


65
66
67
68
69
70
71
# File 'app/controllers/projects/builds_controller.rb', line 65

def raw
  if @build.has_trace?
    send_file @build.path_to_trace, type: 'text/plain; charset=utf-8', disposition: 'inline'
  else
    render_404
  end
end

#retryObject


41
42
43
44
45
46
47
48
# File 'app/controllers/projects/builds_controller.rb', line 41

def retry
  unless @build.retryable?
    return render_404
  end

  build = Ci::Build.retry(@build)
  redirect_to build_path(build)
end

#showObject


28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/projects/builds_controller.rb', line 28

def show
  @builds = @project.ci_commits.find_by_sha(@build.sha).builds.order('id DESC')
  @builds = @builds.where("id not in (?)", @build.id)
  @commit = @build.commit

  respond_to do |format|
    format.html
    format.json do
      render json: @build.to_json(methods: :trace_html)
    end
  end
end

#statusObject


55
56
57
# File 'app/controllers/projects/builds_controller.rb', line 55

def status
  render json: @build.to_json(only: [:status, :id, :sha, :coverage], methods: :sha)
end