Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'app/controllers/projects/ci/lints_controller.rb')
-rw-r--r--app/controllers/projects/ci/lints_controller.rb34
1 files changed, 24 insertions, 10 deletions
diff --git a/app/controllers/projects/ci/lints_controller.rb b/app/controllers/projects/ci/lints_controller.rb
index 73b3eb9c205..c13baaea8c6 100644
--- a/app/controllers/projects/ci/lints_controller.rb
+++ b/app/controllers/projects/ci/lints_controller.rb
@@ -8,16 +8,30 @@ class Projects::Ci::LintsController < Projects::ApplicationController
def create
@content = params[:content]
- result = Gitlab::Ci::YamlProcessor.new_with_validation_errors(@content, yaml_processor_options)
-
- @status = result.valid?
- @errors = result.errors
-
- if result.valid?
- @config_processor = result.config
- @stages = @config_processor.stages
- @builds = @config_processor.builds
- @jobs = @config_processor.jobs
+ @dry_run = params[:dry_run]
+
+ if @dry_run && Gitlab::Ci::Features.lint_creates_pipeline_with_dry_run?(@project)
+ pipeline = Ci::CreatePipelineService
+ .new(@project, current_user, ref: @project.default_branch)
+ .execute(:push, dry_run: true, content: @content)
+
+ @status = pipeline.error_messages.empty?
+ @stages = pipeline.stages
+ @errors = pipeline.error_messages.map(&:content)
+ @warnings = pipeline.warning_messages.map(&:content)
+ else
+ result = Gitlab::Ci::YamlProcessor.new_with_validation_errors(@content, yaml_processor_options)
+
+ @status = result.valid?
+ @errors = result.errors
+ @warnings = result.warnings
+
+ if result.valid?
+ @config_processor = result.config
+ @stages = @config_processor.stages
+ @builds = @config_processor.builds
+ @jobs = @config_processor.jobs
+ end
end
render :show