Class: DeploysController

Inherits:
ApplicationController show all
Includes:
AnsiHelper
Defined in:
app/controllers/deploys_controller.rb

Constant Summary

Constants included from AnsiHelper

AnsiHelper::ANSI_COLOR

Instance Method Summary collapse

Methods included from AnsiHelper

#ansi_to_html

Methods inherited from ApplicationController

#after_sign_in_path_for, #api_authenticate!, #current_project, #expire_revision!, #followed_projects, #no_cache, #read_revision, #require_login, #return_or_cache_revision!, #revision, #save_current_project, #set_current_project, #unfurling?

Methods included from UrlHelper

#edit_release_path, #edit_release_url, #feature_path, #github_commit_range_url, #github_commit_url, #github_project_url, #github_url?, #goldmine_case_number_url, #link_to_project_feature, #new_release_url, #release_path, #release_url, #releases_path

Instance Method Details

#createObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/deploys_controller.rb', line 6

def create
  @project = Project.find_by_slug(params[:project_id])
  unless @project
    render text: "A project with the slug '#{params[:project_id]}' could not be found", status: 404
    return
  end

  @environment = params.fetch(:environment, "").downcase

  sha = params[:commit] || params[:head_long] || params[:head]
  branch = params[:branch]
  deployer = params[:deployer] || params[:user]
  milliseconds = params[:duration]

  Deploy.create!(
    project: @project,
    environment_name: @environment,
    sha: sha,
    branch: branch,
    deployer: deployer,
    duration: milliseconds,
    completed_at: Time.now)

  head 200
end

#showObject



33
34
35
36
37
38
39
40
# File 'app/controllers/deploys_controller.rb', line 33

def show
  @project = Project.find_by_slug! params[:project_id]
  @deploy = @project.deploys.find params[:id]

  if request.format.json?
    render json: { completed: @deploy.completed?, output: ansi_to_html(@deploy.output) }
  end
end