datapipeline 3.2.0: Benachrichtigungen mit Webhook, Slack und E-Mail
This commit is contained in:
@@ -14,13 +14,11 @@ FileUtils.mkdir_p(out)
|
||||
# Zugangsdaten stehen nicht im Skript, sondern in der Verbindungsdatei (Default: config/connections.yml)
|
||||
DataPipeline.connections_file = File.expand_path('config/connections.yml', __dir__)
|
||||
|
||||
# Slack nur, wenn ein Token gesetzt ist; so fällt ein fehlender Token schon vor dem Lauf auf
|
||||
slack = DataPipeline::Slack.new(channel: '#etl') if ENV['SLACK_TOKEN']
|
||||
|
||||
DataPipeline.new do
|
||||
name 'buchungen_export'
|
||||
lock "#{out}/.buchungen.lock" # läuft schon ein Export, bricht dieser ab (Exit-Code 3)
|
||||
history "#{out}/runs.ndjson" # eine JSON-Zeile je Lauf, auch nach Abbruch
|
||||
notify DataPipeline::Slack.new(channel: '#etl') if ENV['SLACK_TOKEN'] # Meldung nur bei Problemen
|
||||
|
||||
read container(:csv, file: "#{DATA}/buchungen.csv", csv: { col_sep: ';' })
|
||||
|
||||
@@ -52,8 +50,5 @@ DataPipeline.new do
|
||||
write container(:csv, file: "#{out}/buchungen_sap.csv", encoding: 'Windows-1252', csv: { col_sep: ';' },
|
||||
columns: %w[belnr buzei datum konto shkzg dmbtr buchungstext])
|
||||
|
||||
on_finish do |stats|
|
||||
puts "#{stats.name}: #{stats}"
|
||||
slack&.send_message("*#{stats.name}*: #{stats}") unless stats.ok?
|
||||
end
|
||||
on_finish { |stats| puts "#{stats.name}: #{stats}" }
|
||||
end.run
|
||||
|
||||
Reference in New Issue
Block a user