Attempt to avoid issues fetching external mapping (columns.csv) for upload.
1 parent 9703d16 commit 57b810eee25ce1249435af236755a151382dca37
@Alex Tucker Alex Tucker authored on 22 Jan 2019
Showing 1 changed file
View
43
src/uk/org/floop/jenkins_pmd/Pipelines.groovy
import org.apache.http.client.fluent.Request
import org.apache.http.entity.ContentType
import org.apache.http.entity.mime.MultipartEntityBuilder
import org.apache.http.util.EntityUtils
 
import java.nio.charset.Charset
 
class Pipelines implements Serializable {
private PMD pmd
private URI apiBase
observationsFilename
)
body.addTextBody('dataset-name', datasetName)
body.addTextBody('dataset-slug', datasetPath)
InputStream mappingStream
if (mapping.startsWith('http')) {
mappingStream = Request
.Get(mapping)
.userAgent(PMDConfig.UA)
.addHeader('Accept', 'text/csv')
.execute().returnContent().asStream()
body.add(
'columns-csv',
Request
.Get(mapping)
.connectTimeout(0).socketTimeout(0)
.userAgent(PMDConfig.UA)
.addHeader('Accept', 'text/csv')
.execute().returnContent().asBytes(),
ContentType.create('text/csv', 'UTF-8'),
mapping
)
} else {
mappingStream = new FilePath(new File(mapping)).read()
body.addBinaryBody(
'columns-csv',
new FilePath(new File(mapping)).read(),
ContentType.create('text/csv', 'UTF-8'),
mapping
)
}
body.addBinaryBody(
'columns-csv',
mappingStream,
ContentType.create('text/csv', 'UTF-8'),
mapping
)
execAndWait(path, body.build())
}
 
def codelist(String draftsetId, String codelistFilename, String codelistName) {