Class: Makit::Cli::PipelineRunCommand
- Inherits:
-
Clamp::Command
- Object
- Clamp::Command
- Makit::Cli::PipelineRunCommand
- Defined in:
- lib/makit/cli/pipeline_commands.rb
Overview
Command to run GitLab CI pipelines
Instance Method Summary collapse
Instance Method Details
#execute ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/makit/cli/pipeline_commands.rb', line 27 def execute # Disable color if requested String.disable_colorization = true if no_color? # Check if pipeline file exists unless File.exist?(file) error "Pipeline file '#{file}' not found" exit(1) end # Parse variables variables = parse_variables # Load and parse pipeline puts "Loading pipeline from #{file}..." if verbose? begin pipeline_content = File.read(file) pipeline = Makit::Gitlab::Pipeline.parse_yaml(pipeline_content) rescue StandardError => e error "Failed to parse pipeline file: #{e.}" exit(1) end # Validate pipeline validation_result = pipeline.validate unless validation_result[:is_valid] error "Pipeline validation failed:" validation_result[:errors].each { |err| error " - #{err}" } exit(1) end # Show warnings if any if validation_result[:warnings].any? warning "Pipeline warnings:" validation_result[:warnings].each { |warn| warning " - #{warn}" } puts end # Show pipeline info show_pipeline_info(pipeline) # Execute pipeline puts "\nExecuting pipeline..." unless dry_run? puts "Dry run mode - no actual execution will occur" if dry_run? start_time = Time.now result = pipeline.execute_pipeline( variables: variables, working_directory: working_directory, podman_executable: podman_executable, dry_run: dry_run? ) end_time = Time.now # Display results display_execution_result(result, start_time, end_time) # Exit with appropriate code success = if result.is_a?(Hash) result[:success] else result.success end exit(success ? 0 : 1) end |