lints_controller.rb 696 Bytes
Newer Older
1
module Ci
2
  class LintsController < ApplicationController
Valery Sizov's avatar
Valery Sizov committed
3
    before_action :authenticate_user!
4 5 6 7 8 9 10 11 12 13 14 15 16 17

    def show
    end

    def create
      if params[:content].blank?
        @status = false
        @error = "Please provide content of .gitlab-ci.yml"
      else
        @config_processor = Ci::GitlabCiYamlProcessor.new params[:content]
        @stages = @config_processor.stages
        @builds = @config_processor.builds
        @status = true
      end
18
    rescue Ci::GitlabCiYamlProcessor::ValidationError, Psych::SyntaxError => e
19 20
      @error = e.message
      @status = false
21
    rescue
22
      @error = 'Undefined error'
23
      @status = false
24 25
    ensure
      render :show
26 27 28
    end
  end
end