diff options
author | Rémy Coutable <remy@rymai.me> | 2016-07-18 11:03:00 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2016-07-18 11:03:00 +0000 |
commit | 550466dd34cb97d4704644b292ab1ef271222981 (patch) | |
tree | 2fc73ab4389f3cf4c1a51f4ed22ef33dad902265 /app | |
parent | 2556d6d34761b6cfc4a81cfcb8f9c4a2fea114dc (diff) | |
parent | ffea9c46000ade225852ee32e90cb8ad0f4f8316 (diff) | |
download | gitlab-ce-550466dd34cb97d4704644b292ab1ef271222981.tar.gz |
Merge branch 'store-variables-and-when-in-builds-table' into 'master'
Store when and yaml variables in builds table
## What does this MR do?
Stores `when` and `yaml_variables` in `ci_builds` table.
## Why was this MR needed?
This is done in order to simplify the code responsible for creating a pipeline builds.
## What are the relevant issue numbers?
This made as a pre-step for https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/5295.
## Does this MR meet the acceptance criteria?
- [x] [CHANGELOG](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CHANGELOG) entry added
- [x] [Documentation created/updated](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/development/doc_styleguide.md)
- [x] API support added
- Tests
- [x] Added for this feature/bug
- [x] All builds are passing
- [x] Conform by the [style guides](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md#style-guides)
- [x] Branch has no merge conflicts with `master` (if you do - rebase it please)
- [ ] [Squashed related commits together](https://git-scm.com/book/en/Git-Tools-Rewriting-History#Squashing-Commits)
See merge request !5296
Diffstat (limited to 'app')
-rw-r--r-- | app/models/ci/build.rb | 34 | ||||
-rw-r--r-- | app/services/ci/create_builds_service.rb | 4 |
2 files changed, 12 insertions, 26 deletions
diff --git a/app/models/ci/build.rb b/app/models/ci/build.rb index b24527247e0..ffac3a22efc 100644 --- a/app/models/ci/build.rb +++ b/app/models/ci/build.rb @@ -5,6 +5,7 @@ module Ci belongs_to :erased_by, class_name: 'User' serialize :options + serialize :yaml_variables validates :coverage, numericality: true, allow_blank: true validates_presence_of :ref @@ -52,6 +53,8 @@ module Ci new_build.stage = build.stage new_build.stage_idx = build.stage_idx new_build.trigger_request = build.trigger_request + new_build.yaml_variables = build.yaml_variables + new_build.when = build.when new_build.user = user new_build.environment = build.environment new_build.save @@ -118,7 +121,12 @@ module Ci end def variables - predefined_variables + yaml_variables + project_variables + trigger_variables + variables = [] + variables += predefined_variables + variables += yaml_variables if yaml_variables + variables += project_variables + variables += trigger_variables + variables end def merge_request @@ -395,30 +403,6 @@ module Ci self.update(erased_by: user, erased_at: Time.now, artifacts_expire_at: nil) end - def yaml_variables - global_yaml_variables + job_yaml_variables - end - - def global_yaml_variables - if pipeline.config_processor - pipeline.config_processor.global_variables.map do |key, value| - { key: key, value: value, public: true } - end - else - [] - end - end - - def job_yaml_variables - if pipeline.config_processor - pipeline.config_processor.job_variables(name).map do |key, value| - { key: key, value: value, public: true } - end - else - [] - end - end - def project_variables project.variables.map do |variable| { key: variable.key, value: variable.value, public: false } diff --git a/app/services/ci/create_builds_service.rb b/app/services/ci/create_builds_service.rb index 2dcb052d274..3b21f0acb96 100644 --- a/app/services/ci/create_builds_service.rb +++ b/app/services/ci/create_builds_service.rb @@ -36,7 +36,9 @@ module Ci :allow_failure, :stage, :stage_idx, - :environment) + :environment, + :when, + :yaml_variables) build_attrs.merge!(pipeline: @pipeline, ref: @pipeline.ref, |