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