Skip to content

Commit

Permalink
fix failure sending json file
Browse files Browse the repository at this point in the history
  • Loading branch information
ssadedin committed Jun 23, 2018
1 parent 8bac2f5 commit 71a45e3
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/main/groovy/bpipe/Sender.groovy
Expand Up @@ -78,7 +78,19 @@ class Sender {
}

Sender json(Closure c) {
this.content = JsonOutput.toJson(c())
Object result = c()
if(result instanceof PipelineInput) {
result = Pipeline.file(result)
}

// If it is a file object, send the content of the file, not the literal file object
if(result instanceof File) {
log.info "Sent JSON resolves to file: sending content of file $result"
this.content = result.text
}
else
this.content = JsonOutput.toJson(result)

this.contentType = "application/json"
this.defaultSubject = "JSON content from stage ${ctx.stageName}"
return this
Expand Down

0 comments on commit 71a45e3

Please sign in to comment.