You've already forked sap-jenkins-library
mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-09-16 09:26:22 +02:00
jenkinsMaterialzeLog: use log without binary annotations (#1542)
* jenkinsMaterialzeLog: use log without binary annotations * test fixed
This commit is contained in:
@@ -1,4 +1,9 @@
|
||||
import hudson.FilePath
|
||||
import hudson.console.AnnotatedLargeText
|
||||
import java.io.Writer
|
||||
import groovy.mock.interceptor.MockFor
|
||||
import java.lang.Integer
|
||||
|
||||
import org.junit.Assert
|
||||
import org.junit.Rule
|
||||
import org.junit.Test
|
||||
@@ -27,6 +32,10 @@ class JenkinsMaterializeLogTest extends BasePiperTest {
|
||||
}
|
||||
}
|
||||
|
||||
class AnnotatedLargeTextMock {
|
||||
void writeLogTo(i, out) {}
|
||||
}
|
||||
|
||||
@Rule
|
||||
public RuleChain ruleChain = Rules
|
||||
.getCommonRules(this)
|
||||
@@ -40,7 +49,7 @@ class JenkinsMaterializeLogTest extends BasePiperTest {
|
||||
void testMaterializeLog() {
|
||||
def map = [script: nullScript, jenkinsUtilsStub: new JenkinsUtilsMock()]
|
||||
def body = { name -> def msg = "hello " + name }
|
||||
binding.setVariable('currentBuild', [result: 'UNSTABLE', rawBuild: [getLogInputStream: {return new StringBufferInputStream("this is the input")}]])
|
||||
binding.setVariable('currentBuild', [result: 'UNSTABLE', rawBuild: [getLogText: { return new AnnotatedLargeTextMock() } ]])
|
||||
binding.setVariable('env', [NODE_NAME: 'anynode', WORKSPACE: '.'])
|
||||
stepRule.step.jenkinsMaterializeLog(map, body)
|
||||
}
|
||||
|
@@ -37,9 +37,7 @@ void call(Map parameters = [:], body) {
|
||||
|
||||
@NonCPS
|
||||
def writeLogToFile(fp) {
|
||||
def logInputStream = currentBuild.rawBuild.getLogInputStream()
|
||||
fp.copyFrom(logInputStream)
|
||||
logInputStream.close()
|
||||
currentBuild.rawBuild.getLogText().writeLogTo(0, fp.write())
|
||||
}
|
||||
|
||||
@NonCPS
|
||||
|
Reference in New Issue
Block a user