summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorValery Sizov <vsv2711@gmail.com>2015-06-02 17:20:50 +0300
committerValery Sizov <vsv2711@gmail.com>2015-06-03 16:36:54 +0300
commit2333fe7e992cc20a283cd1759a3d14cfbb160ebd (patch)
treeb6f415915da6e03485dc0f534a4d034f9f2519a9 /lib
parentd1ed2c41114d6f9827b0a9fb1b5afb73849765ba (diff)
downloadgitlab-ci-2333fe7e992cc20a283cd1759a3d14cfbb160ebd.tar.gz
improve migrator of deprecated jobs
Diffstat (limited to 'lib')
-rw-r--r--lib/gitlab_ci_yaml_processor.rb16
1 files changed, 12 insertions, 4 deletions
diff --git a/lib/gitlab_ci_yaml_processor.rb b/lib/gitlab_ci_yaml_processor.rb
index 8adea84..0d893df 100644
--- a/lib/gitlab_ci_yaml_processor.rb
+++ b/lib/gitlab_ci_yaml_processor.rb
@@ -13,7 +13,7 @@ class GitlabCiYamlProcessor
normalized_jobs.map do |job|
{
name: job[:name],
- commands: "#{@before_script.join("\n")}\n#{job[:script]}",
+ commands: "#{normalized_script(@before_script)}\n#{job[:script]}",
tag_list: job[:runner],
branches: job[:branches],
tags: job[:tag]
@@ -25,7 +25,7 @@ class GitlabCiYamlProcessor
normalized_deploy_jobs.map do |job|
{
name: job[:name],
- commands: "#{@before_script.join("\n")}\n#{job[:script]}",
+ commands: "#{normalized_script(@before_script)}\n#{job[:script]}",
deploy: true,
refs: job[:refs],
tag_list: job[:runner]
@@ -71,7 +71,7 @@ class GitlabCiYamlProcessor
{ script: job, runner: "", name: job[0..10], branches: true, tags: true }
else
{
- script: job[:script].strip,
+ script: normalized_script(job[:script]),
runner: job[:runner] || "",
name: job[:name] || job[:script][0..10],
branches: job[:branches].nil? ? true : job[:branches],
@@ -87,7 +87,7 @@ class GitlabCiYamlProcessor
{ script: job, refs: [], name: job[0..10].strip }
else
{
- script: job[:script].strip,
+ script: normalized_script(job[:script]),
refs: (job[:refs] || "").split(",").map(&:strip),
name: job[:name] || job[:script][0..10].strip,
runner: job[:runner] || "",
@@ -95,4 +95,12 @@ class GitlabCiYamlProcessor
end
end
end
+
+ def normalized_script(script)
+ if script.is_a? Array
+ script.map(&:strip).join("\n")
+ else
+ script.strip
+ end
+ end
end