diff --git a/src/uk/org/floop/jenkins_pmd/Drafter.groovy b/src/uk/org/floop/jenkins_pmd/Drafter.groovy index 973250c..f2f2420 100644 --- a/src/uk/org/floop/jenkins_pmd/Drafter.groovy +++ b/src/uk/org/floop/jenkins_pmd/Drafter.groovy @@ -1,6 +1,7 @@ package uk.org.floop.jenkins_pmd import groovy.json.JsonSlurper +import hudson.FilePath import org.apache.http.HttpHost import org.apache.http.HttpResponse import org.apache.http.client.fluent.Executor @@ -145,7 +146,7 @@ Request.Put(apiBase.resolve(path)) .addHeader("Accept", "application/json") .userAgent(PMDConfig.UA) - .bodyFile(new File(fileName), ContentType.create(mimeType, encoding)) + .bodyStream(new FilePath(new File(fileName)).read(), ContentType.create(mimeType, encoding)) ).returnResponse() if (response.getStatusLine().statusCode == 202) { def jobObj = new JsonSlurper().parse(EntityUtils.toByteArray(response.getEntity())) diff --git a/src/uk/org/floop/jenkins_pmd/Pipelines.groovy b/src/uk/org/floop/jenkins_pmd/Pipelines.groovy index 2ba085e..67f13ae 100644 --- a/src/uk/org/floop/jenkins_pmd/Pipelines.groovy +++ b/src/uk/org/floop/jenkins_pmd/Pipelines.groovy @@ -2,6 +2,7 @@ import groovy.json.JsonOutput import groovy.json.JsonSlurper +import hudson.FilePath import org.apache.http.HttpHost import org.apache.http.HttpResponse import org.apache.http.client.fluent.Executor @@ -46,7 +47,7 @@ ])) body.addBinaryBody( 'observations-csv', - new FileInputStream(observationsFilename), + new FilePath(new File(observationsFilename)).read(), ContentType.create('text/csv', 'UTF-8'), observationsFilename ) @@ -60,7 +61,7 @@ .addHeader('Accept', 'text/csv') .execute().returnContent().asStream() } else { - mappingStream = new FileInputStream(mapping) + mappingStream = new FilePath(mapping).read() } body.addBinaryBody( 'columns-csv',