payload.json

master
Izimic 2020-11-27 16:59:17 +01:00
parent 62f1a3215d
commit a99b1f4f9e
1 changed files with 5 additions and 1 deletions

View File

@ -46,6 +46,7 @@ OptionParser.parse do |parser|
end end
scriptfile = "on-push" scriptfile = "on-push"
jsonfile = "payload.json"
server = HTTP::Server.new do |context| server = HTTP::Server.new do |context|
if context.request.method != "POST" || context.request.path != "/" if context.request.method != "POST" || context.request.path != "/"
@ -55,6 +56,7 @@ server = HTTP::Server.new do |context|
path_project = storage + "/" + payload.project path_project = storage + "/" + payload.project
path_scriptfile = path_project + "/" + scriptfile path_scriptfile = path_project + "/" + scriptfile
path_jsonfile = path_project + "/" + jsonfile
status = false status = false
@ -66,11 +68,13 @@ server = HTTP::Server.new do |context|
STDERR.puts "ERROR: Scriptfile not found" STDERR.puts "ERROR: Scriptfile not found"
status = false status = false
else else
context.response.content_type = "text/plain" File.write(path_jsonfile, payload.content)
status = Process.run command: "sh", args: [scriptfile], shell: true, status = Process.run command: "sh", args: [scriptfile], shell: true,
error: STDERR, output: STDOUT, chdir: path_project error: STDERR, output: STDOUT, chdir: path_project
end end
end end
context.response.content_type = "text/plain"
if status if status
context.response.print "SUCCESS" context.response.print "SUCCESS"
else else