diff --git a/test/groovy/util/JenkinsWriteFileRule.groovy b/test/groovy/util/JenkinsWriteFileRule.groovy index 6a59dcf32..5c48b2748 100644 --- a/test/groovy/util/JenkinsWriteFileRule.groovy +++ b/test/groovy/util/JenkinsWriteFileRule.groovy @@ -1,6 +1,9 @@ package util import com.lesfurets.jenkins.unit.BasePipelineTest + +import static org.junit.Assert.assertNotNull +import static org.junit.Assert.assertTrue import org.junit.rules.TestRule import org.junit.runner.Description import org.junit.runners.model.Statement @@ -25,7 +28,17 @@ class JenkinsWriteFileRule implements TestRule { @Override void evaluate() throws Throwable { - testInstance.helper.registerAllowedMethod( 'writeFile', [Map.class], {m -> files[m.file] = m.text.toString()}) + testInstance.helper.registerAllowedMethod( 'writeFile', [Map.class], { m -> + assertNotNull(m.file) + assertTrue(m.file instanceof CharSequence) + assertNotNull(m.text) + assertTrue(m.text instanceof CharSequence) + if (m.encoding) { + assertTrue(m.encoding instanceof CharSequence) + // Would be nice to actually handle encoding + } + files[m.file] = m.text + }) base.evaluate() } diff --git a/vars/debugReportArchive.groovy b/vars/debugReportArchive.groovy index ebb0d153b..68de7d39c 100644 --- a/vars/debugReportArchive.groovy +++ b/vars/debugReportArchive.groovy @@ -63,7 +63,7 @@ void call(Map parameters = [:]) { echo result.contents } - script.writeFile file: result.fileName, text: result + script.writeFile file: result.fileName, text: result.contents script.archiveArtifacts artifacts: result.fileName echo "Successfully archived debug report as '${result.fileName}'" } catch (Exception e) {