BigW Consortium Gitlab

lints_controller.rb 716 Bytes
Newer Older
1
module Ci
2
  class LintsController < ApplicationController
Valery Sizov committed
3
    before_action :authenticate_user!
4 5 6 7 8

    def show
    end

    def create
9 10 11
      @content = params[:content]

      if @content.blank?
12 13 14
        @status = false
        @error = "Please provide content of .gitlab-ci.yml"
      else
15
        @config_processor = Ci::GitlabCiYamlProcessor.new(@content)
16 17 18 19
        @stages = @config_processor.stages
        @builds = @config_processor.builds
        @status = true
      end
20
    rescue Ci::GitlabCiYamlProcessor::ValidationError, Psych::SyntaxError => e
21 22
      @error = e.message
      @status = false
23
    rescue
24
      @error = 'Undefined error'
25
      @status = false
26 27
    ensure
      render :show
28 29 30
    end
  end
end