diff options
author | Valery Sizov <vsv2711@gmail.com> | 2015-06-12 17:50:55 +0300 |
---|---|---|
committer | Valery Sizov <vsv2711@gmail.com> | 2015-06-12 17:51:33 +0300 |
commit | f70fa3eb45104304a1ea5a33edb0ea8bea3f0d32 (patch) | |
tree | 98c1f57d2e62a68ad5b645da9d48200f8687300e /db | |
parent | 6d75d0f8bc7fc9c5bc6bf8519fffda53971dc216 (diff) | |
download | gitlab-ci-f70fa3eb45104304a1ea5a33edb0ea8bea3f0d32.tar.gz |
migration jobs to yaml
Diffstat (limited to 'db')
-rw-r--r-- | db/migrate/20150601043226_migrate_jobs_to_yaml.rb (renamed from db/migrate/20150601043225_migrate_jobs_to_yaml.rb) | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/db/migrate/20150601043225_migrate_jobs_to_yaml.rb b/db/migrate/20150601043226_migrate_jobs_to_yaml.rb index aaf10a7..ba7a7dc 100644 --- a/db/migrate/20150601043225_migrate_jobs_to_yaml.rb +++ b/db/migrate/20150601043226_migrate_jobs_to_yaml.rb @@ -5,9 +5,9 @@ class MigrateJobsToYaml < ActiveRecord::Migration def up select_all("SELECT * FROM projects").each do |project| - config = {jobs: [], deploy_jobs: []} + config = {} - concatenate_expression = if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' + concatenate_expression = if ActiveRecord::Base.connection.adapter_name == 'PostgreSQL' "string_agg(tags.name, ',')" else "GROUP_CONCAT(tags.name SEPARATOR ',')" @@ -24,26 +24,31 @@ class MigrateJobsToYaml < ActiveRecord::Migration # Create Jobs select_all(sql).each do |job| - config[:jobs] << { - script: job["commands"] && job["commands"].split("\n").map(&:strip), - name: job["name"], - branches: parse_boolean_value(job["build_branches"]), - tags: parse_boolean_value(job["build_tags"]), - runner: job["tags"] + config[job["name"].to_s] = { + test: job["commands"] && job["commands"].split("\n").map(&:strip), + tags: job["tags"] } + + except = build_except_param(parse_boolean_value(job["build_branches"]), parse_boolean_value(job["build_tags"])) + + if except + config[job["name"].to_s][:except] = except + end end # Create Deploy Jobs select_all(sql.sub("parallel", 'deploy')).each do |job| - config[:deploy_jobs] << { - script: job["commands"] && job["commands"].split("\n").map(&:strip), - name: job["name"], - refs: job["refs"], - runner: job["tags"] + config[job["name"].to_s] = { + deploy: job["commands"] && job["commands"].split("\n").map(&:strip), + tags: job["tags"] } - end - config[:skip_refs] = project["skip_refs"] + except = build_except_param(parse_boolean_value(job["build_branches"]), parse_boolean_value(job["build_tags"])) + + if except + config[job["name"].to_s][:except] = except + end + end yaml_config = YAML.dump(config.deep_stringify_keys) @@ -62,4 +67,16 @@ class MigrateJobsToYaml < ActiveRecord::Migration def parse_boolean_value(value) [ true, 1, '1', 't', 'T', 'true', 'TRUE', 'on', 'ON' ].include?(value) end + + def build_except_param(branches, tags) + unless branches + return ["branches"] + end + + unless tags + return ["tags"] + end + + false + end end |