option -e

master
Izimic 2020-12-16 00:43:00 +01:00
parent 9f0ad6c81d
commit 8ea48ba4ee
2 changed files with 34 additions and 4 deletions

25
default.zsh Normal file
View File

@ -0,0 +1,25 @@
#!/usr/bin/env zsh
PROJECT=dodb.cr
GIT=$(cat payload.json | jq '.repository.clone_url')
ENV=debian
SPECS=("crystal spec spec/test.cr --tap")
echo $GIT
git clone $GIT
cd $PROJECT
shards install
shards build
REV=$(git rev-parse HEAD)
for i in ${SPECS[*]}
do
echo $i
/bin/sh -c $i | ../tap-aggregator add $PROJECT $ENV $REV
done
exit 1

View File

@ -6,7 +6,7 @@ VERSION = 0.1
port = 3000 port = 3000
storage = "webhooksd-data" storage = "webhooksd-data"
scriptfile = "on-push" scriptfile = "default.zsh"
jsonfile = "payload.json" jsonfile = "payload.json"
args = [] of String args = [] of String
@ -31,6 +31,10 @@ OptionParser.parse do |parser|
storage = s storage = s
end end
parser.on "-e SCRIPT", "--script=SCRIPT", "Default: #{scriptfile}" do |s|
scriptfile = s
end
parser.invalid_option do |flag| parser.invalid_option do |flag|
STDERR.puts "ERROR: #{flag} is not a valid option." STDERR.puts "ERROR: #{flag} is not a valid option."
STDERR.puts parser STDERR.puts parser
@ -54,7 +58,7 @@ server = HTTP::Server.new do |context|
payload = Payload.new(context.request) payload = Payload.new(context.request)
path_project = storage + "/" + payload.project path_project = storage + "/" + payload.project
path_scriptfile = path_project + "/" + scriptfile path_scriptfile = "../../../" + scriptfile
path_jsonfile = path_project + "/" + jsonfile path_jsonfile = path_project + "/" + jsonfile
status = false status = false
@ -63,12 +67,13 @@ server = HTTP::Server.new do |context|
STDERR.puts "ERROR: Project #{payload.project} not found" STDERR.puts "ERROR: Project #{payload.project} not found"
status = false status = false
else else
if File.exists?(path_scriptfile) == false if File.exists?(scriptfile) == false
p scriptfile
STDERR.puts "ERROR: Scriptfile not found" STDERR.puts "ERROR: Scriptfile not found"
status = false status = false
else else
File.write(path_jsonfile, payload.content) File.write(path_jsonfile, payload.content)
status = Process.run command: "zsh", args: [scriptfile], shell: true, status = Process.run command: "zsh", args: [path_scriptfile], shell: true,
error: STDERR, output: STDOUT, chdir: path_project error: STDERR, output: STDOUT, chdir: path_project
end end
end end