diff options
author | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-30 15:30:45 +0200 |
---|---|---|
committer | Grzegorz Bizon <grzesiek.bizon@gmail.com> | 2017-05-30 15:30:45 +0200 |
commit | 805715cc68aabb6992a63356ec7c19940f52c93a (patch) | |
tree | d17df258863c6891f47015af99c1652299227c44 /lib | |
parent | 325b2d9329ae90748dd0db749f9ebc0800eaea75 (diff) | |
download | gitlab-ce-805715cc68aabb6992a63356ec7c19940f52c93a.tar.gz |
Add stage seed class that represents attributes
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ci/gitlab_ci_yaml_processor.rb | 3 | ||||
-rw-r--r-- | lib/gitlab/ci/stage/seed.rb | 38 |
2 files changed, 39 insertions, 2 deletions
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb index 17a3cdc714c..aa6c94f26c8 100644 --- a/lib/ci/gitlab_ci_yaml_processor.rb +++ b/lib/ci/gitlab_ci_yaml_processor.rb @@ -81,8 +81,7 @@ module Ci dependencies: job[:dependencies], after_script: job[:after_script], environment: job[:environment] - }.compact - } + }.compact } end def self.validation_message(content) diff --git a/lib/gitlab/ci/stage/seed.rb b/lib/gitlab/ci/stage/seed.rb new file mode 100644 index 00000000000..95237bff5d7 --- /dev/null +++ b/lib/gitlab/ci/stage/seed.rb @@ -0,0 +1,38 @@ +module Gitlab + module Ci + module Stage + class Seed + attr_reader :name, :builds + + def initialize(name:, builds:) + @name = name + @builds = builds + end + + def pipeline=(pipeline) + trigger_request = pipeline.trigger_requests.first + + @builds.each do |attributes| + attributes.merge!( + pipeline: pipeline, + project: pipeline.project, + ref: pipeline.ref, + tag: pipeline.tag, + trigger_request: trigger_request + ) + end + end + + def user=(current_user) + @builds.each do |attributes| + attributes.merge!(user: current_user) + end + end + + def to_attributes + { name: @name, builds_attributes: @builds } + end + end + end + end +end |