[why] if job.yaml define: on_fail: on_fail_sleep: XXXX(time) XXXX: XXXX ... [how] By sh_on_fail, it will appear in job.sh: on_fail() { sleep: on_fail[on_fail_sleep] XXXX: XXXX ... }
Signed-off-by: Hu XueJiao huxuejiao1@huawei.com --- lib/job2sh.rb | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-)
diff --git a/lib/job2sh.rb b/lib/job2sh.rb index 9c95ff4b..974b78b7 100755 --- a/lib/job2sh.rb +++ b/lib/job2sh.rb @@ -142,7 +142,7 @@ class Job2sh < Job end
def parse_one(ancestors, key, val, pass) - if ['pp', 'define_files', 'monitors'].include?(key) + if ['pp', 'define_files', 'monitors', 'on_fail'].include?(key) return false end tabs = indent(ancestors) @@ -266,9 +266,11 @@ class Job2sh < Job sh_run_job(job) local_script_lines += @script_lines
- sh_extract_stats(job) local_script_lines += @script_lines + + sh_on_fail() + local_script_lines += @script_lines
sh_define_files()
@@ -338,6 +340,23 @@ class Job2sh < Job @script_lines end
+ def sh_on_fail + @script_lines = [] + + job = (@jobx || @job) + on_fail = job['on_fail'] || {} + + out_line 'on_fail()' + out_line '{' + out_line + on_fail.each do |key, val| + if key == "on_fail_sleep" + out_line "\tsleep #{on_fail[key]}" + end + end + out_line '}' + end + def sh_define_files @script_lines = []