summaryrefslogtreecommitdiff
path: root/app/services/ci/create_pipeline_stages_service.rb
blob: f2c175adee67d07e9375d8fb969471476c5918fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
module Ci
  class CreatePipelineStagesService < BaseService
    def execute(pipeline)
      pipeline.stage_seeds.each do |seed|
        seed.user = current_user

        seed.create! do |build|
          ##
          # Create the environment before the build starts. This sets its slug and
          # makes it available as an environment variable
          #
          if build.has_environment?
            environment_name = build.expanded_environment_name
            project.environments.find_or_create_by(name: environment_name)
          end
        end
      end
    end
  end
end