1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2024-12-12 10:55:20 +02:00

do not swallow exception triggered inside SWA handling (#1839)

* do not swallow exception triggered inside SWA handling

--> write it to the log

The real change is in src/com/sap/piper/Utils.groovy
All the changes in the tests are dealing with mocking the echo method
used in the Utils class mentioned above.
This commit is contained in:
Marcus Holl 2020-09-24 13:47:20 +02:00 committed by GitHub
parent 75e696ad7b
commit fd568c9174
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
35 changed files with 298 additions and 4 deletions

View File

@ -118,7 +118,8 @@ void pushToSWA(Map parameters, Map config) {
Telemetry.notify(this, config, parameters)
} catch (ignore) {
// some error occurred in telemetry reporting. This should not break anything though.
// some error occured in telemetry reporting. This should not break anything though.
echo "[${parameters.step}] Telemetry Report failed: ${ignore.getMessage()}"
}
}

View File

@ -1,3 +1,4 @@
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -5,6 +6,7 @@ import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain
import com.sap.piper.GitUtils
import com.sap.piper.Utils
import hudson.AbortException
import util.BasePiperTest
@ -103,6 +105,13 @@ class ArtifactSetVersionTest extends BasePiperTest {
shellRule.setReturnValue('git diff --quiet HEAD', 0)
helper.registerAllowedMethod('fileExists', [String.class], {true})
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,4 +1,5 @@
#!groovy
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -11,6 +12,8 @@ import util.JenkinsShellCallRule
import util.JenkinsStepRule
import util.Rules
import com.sap.piper.Utils
import static org.hamcrest.CoreMatchers.containsString
import static org.hamcrest.CoreMatchers.hasItem
import static org.hamcrest.CoreMatchers.is
@ -50,6 +53,12 @@ class BuildExecuteTest extends BasePiperTest {
@Before
void init() {
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,3 +1,4 @@
import org.junit.Before
import org.junit.After
import org.junit.Rule
import org.junit.Test
@ -7,6 +8,7 @@ import org.junit.rules.RuleChain
import com.sap.piper.cm.BackendType
import com.sap.piper.cm.ChangeManagement
import com.sap.piper.cm.ChangeManagementException
import com.sap.piper.Utils
import hudson.AbortException
import util.BasePiperTest
@ -32,9 +34,15 @@ class CheckChangeInDevelopmentTest extends BasePiperTest {
.around(new JenkinsCredentialsRule(this)
.withCredentials('CM', 'anonymous', '********'))
@Before
public void setup() {
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
cmUtilReceivedParams.clear()
Utils.metaClass = null
}
private Map cmUtilReceivedParams = [:]

View File

@ -1,10 +1,12 @@
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
import org.junit.Ignore
import com.sap.piper.Utils
import util.BasePiperTest
import static org.junit.Assert.assertEquals
@ -39,6 +41,12 @@ class ChecksPublishResultsTest extends BasePiperTest {
helper.registerAllowedMethod("archiveArtifacts", [Map.class], {
parameters -> archiveStepPatterns.push(parameters.artifacts)
})
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,4 +1,5 @@
#!groovy
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -12,6 +13,8 @@ import util.JenkinsShellCallRule
import util.JenkinsStepRule
import util.Rules
import com.sap.piper.Utils
import static org.hamcrest.CoreMatchers.containsString
import static org.hamcrest.CoreMatchers.hasItem
import static org.hamcrest.CoreMatchers.is
@ -76,6 +79,12 @@ class ContainerPushToRegistryTest extends BasePiperTest {
@Before
void init() {
binding.setVariable('docker', new DockerMock('test'))
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,12 +1,13 @@
import com.sap.piper.JenkinsUtils
import com.sap.piper.Utils
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain
import groovy.json.JsonSlurper
import util.BasePiperTest
import util.JenkinsDockerExecuteRule
@ -115,6 +116,12 @@ class DockerExecuteOnKubernetesTest extends BasePiperTest {
stashList.add(m)
})
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -2,6 +2,8 @@ import com.sap.piper.k8s.ContainerMap
import com.sap.piper.JenkinsUtils
import com.sap.piper.SidecarUtils
import com.sap.piper.Utils
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -45,6 +47,12 @@ class DockerExecuteTest extends BasePiperTest {
JenkinsUtils.metaClass.static.isPluginActive = { def s -> new PluginMock(s).isActive() }
binding.setVariable('docker', docker)
shellRule.setReturnValue(JenkinsShellCallRule.Type.REGEX, "docker .*", 0)
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,5 +1,6 @@
import static org.junit.Assert.assertEquals
import hudson.AbortException
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -11,6 +12,7 @@ import util.JenkinsReadYamlRule
import util.JenkinsShellCallRule
import util.JenkinsStepRule
import util.Rules
import com.sap.piper.Utils
class DubExecuteTest extends BasePiperTest {
@ -32,6 +34,12 @@ class DubExecuteTest extends BasePiperTest {
@Before
void init() {
helper.registerAllowedMethod 'fileExists', [String], { s -> s == 'dub.json' }
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -13,12 +13,14 @@ import static org.junit.Assert.assertThat
import org.hamcrest.Matchers
import org.junit.Assert
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
import com.sap.piper.JenkinsUtils
import com.sap.piper.Utils
import util.BasePiperTest
import util.JenkinsCredentialsRule
@ -94,6 +96,13 @@ class FioriOnCloudPlatformPipelineTest extends BasePiperTest {
helper.registerAllowedMethod('mtaBuild', [Map], {
m -> m.script.commonPipelineEnvironment.mtarFilePath = 'test.mtar'
})
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,5 +1,6 @@
import hudson.AbortException
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -16,6 +17,8 @@ import util.Rules
import static org.junit.Assert.assertThat
import static org.hamcrest.Matchers.*
import com.sap.piper.Utils
class HadolintExecuteTest extends BasePiperTest {
private ExpectedException thrown = new ExpectedException().none()
@ -42,6 +45,12 @@ class HadolintExecuteTest extends BasePiperTest {
helper.registerAllowedMethod 'checkStyle', [Map], { m -> assertThat(m.pattern, is('hadolint.xml')); return 'checkstyle' }
helper.registerAllowedMethod 'recordIssues', [Map], { m -> assertThat(m.tools, hasItem('checkstyle')) }
helper.registerAllowedMethod 'archiveArtifacts', [String], { String p -> assertThat('hadolint.xml', is(p)) }
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,3 +1,4 @@
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -9,6 +10,8 @@ import util.JenkinsReadYamlRule
import util.JenkinsStepRule
import util.Rules
import com.sap.piper.Utils
import static org.hamcrest.Matchers.*
import static org.junit.Assert.assertThat
@ -34,6 +37,12 @@ class HealthExecuteCheckTest extends BasePiperTest {
helper.registerAllowedMethod('sh', [Map.class], {map ->
return map.script == command1 || map.script == command2 ? "200" : "404"
})
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,7 +1,9 @@
import com.sap.piper.DefaultValueCache
import com.sap.piper.JenkinsUtils
import com.sap.piper.analytics.InfluxData
import com.sap.piper.Utils
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -67,8 +69,15 @@ class InfluxWriteDataTest extends BasePiperTest {
helper.registerAllowedMethod('step', [Map.class],{m -> stepMap = m})
helper.registerAllowedMethod('influxDbPublisher', [Map.class],{m -> stepMap = m})
Utils.metaClass.echo = { def m -> }
}
@After
void teadDown() {
Utils.metaClass = null
}
@Test
void testInfluxWriteDataWithDefault() throws Exception {

View File

@ -1,8 +1,10 @@
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
import util.*
import com.sap.piper.Utils
import static org.hamcrest.Matchers.*
import static org.junit.Assert.assertThat
@ -32,6 +34,13 @@ class MailSendNotificationTest extends BasePiperTest {
nullScript.commonPipelineEnvironment.configuration['steps']['mailSendNotification'] = nullScript.commonPipelineEnvironment.configuration['steps']['mailSendNotification'] ?: [:]
helper.registerAllowedMethod('requestor', [], { -> return [$class: 'RequesterRecipientProvider']})
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,10 +1,12 @@
import static org.junit.Assert.assertFalse
import static org.junit.Assert.assertTrue
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain
import com.sap.piper.Utils
import util.*
@ -126,8 +128,15 @@ class MulticloudDeployTest extends BasePiperTest {
helper.registerAllowedMethod('echo', [CharSequence.class], {})
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test
void errorNoTargetsDefined() {

View File

@ -77,11 +77,14 @@ class NeoDeployTest extends BasePiperTest {
helper.registerAllowedMethod('pwd', [], { return './' })
nullScript.commonPipelineEnvironment.configuration = [steps: [neoDeploy: [neo: [host: 'test.deploy.host.com', account: 'trialuser123']]]]
Utils.metaClass.echo = { def m -> }
}
@After
void tearDown() {
GroovySystem.metaClassRegistry.removeMetaClass(StepAssertions)
GroovySystem.metaClassRegistry.removeMetaClass(Utils)
}
@Test

View File

@ -1,3 +1,4 @@
import org.junit.After
import org.junit.Before
import org.junit.Test
import org.junit.Rule
@ -22,6 +23,8 @@ import util.Rules
import org.junit.rules.ExpectedException
import util.JenkinsCredentialsRule
import com.sap.piper.Utils
class NewmanExecuteTest extends BasePiperTest {
private ExpectedException thrown = ExpectedException.none()
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
@ -62,6 +65,12 @@ class NewmanExecuteTest extends BasePiperTest {
files = [new File(map.glob)]
return files.toArray()
})
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,3 +1,4 @@
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -10,6 +11,8 @@ import util.JenkinsReadYamlRule
import util.JenkinsStepRule
import util.Rules
import com.sap.piper.Utils
import static org.junit.Assert.assertFalse
import static org.junit.Assert.assertTrue
import static org.junit.Assert.assertTrue
@ -58,6 +61,13 @@ class NpmExecuteEndToEndTestsTest extends BasePiperTest {
credentialsRule.reset()
.withCredentials('testCred', 'test_cf', '********')
.withCredentials('testCred2', 'test_other', '**')
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,5 +1,6 @@
import static org.junit.Assert.assertEquals
import hudson.AbortException
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -11,6 +12,7 @@ import util.JenkinsReadYamlRule
import util.JenkinsShellCallRule
import util.JenkinsStepRule
import util.Rules
import com.sap.piper.Utils
class NpmExecuteTest extends BasePiperTest {
@ -32,6 +34,12 @@ class NpmExecuteTest extends BasePiperTest {
@Before
void init() {
helper.registerAllowedMethod 'fileExists', [String], { s -> s == 'package.json' }
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,12 +1,16 @@
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
import util.*
import com.sap.piper.Utils
import static org.hamcrest.Matchers.containsString
import static org.junit.Assert.assertFalse
import static org.junit.Assert.assertThat
class PipelineStashFilesAfterBuildTest extends BasePiperTest {
JenkinsStepRule stepRule = new JenkinsStepRule(this)
JenkinsLoggingRule loggingRule = new JenkinsLoggingRule(this)
@ -20,6 +24,16 @@ class PipelineStashFilesAfterBuildTest extends BasePiperTest {
.around(loggingRule)
.around(stepRule)
@Before
public void setup() {
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test
void testStashAfterBuild() {
helper.registerAllowedMethod("fileExists", [String.class], {

View File

@ -1,8 +1,12 @@
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.RuleChain
import util.*
import com.sap.piper.Utils
import static org.hamcrest.Matchers.containsString
import static org.junit.Assert.*
@ -12,6 +16,16 @@ class PipelineStashFilesBeforeBuildTest extends BasePiperTest {
JenkinsShellCallRule shellRule = new JenkinsShellCallRule(this)
//JenkinsReadJsonRule readJsonRule = new JenkinsReadJsonRule(this)
@Before
public void setup() {
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Rule
public RuleChain rules = Rules
.getCommonRules(this)

View File

@ -21,6 +21,8 @@ import util.JenkinsReadYamlRule
import util.JenkinsStepRule
import util.JenkinsShellCallRule
import com.sap.piper.Utils
import static com.lesfurets.jenkins.unit.MethodSignature.method
class PiperPublishWarningsTest extends BasePiperTest {
@ -60,14 +62,16 @@ class PiperPublishWarningsTest extends BasePiperTest {
}
JenkinsUtils.metaClass.static.getFullBuildLog = { def currentBuild -> return ""}
JenkinsUtils.metaClass.static.isPluginActive = { id -> return true}
}
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
JenkinsUtils.metaClass.addWarningsNGParser = null
JenkinsUtils.metaClass.static.getFullBuildLog = null
JenkinsUtils.metaClass.static.isPluginActive = null
Utils.metaClass = null
}
@Test

View File

@ -1,4 +1,6 @@
import com.sap.piper.DefaultValueCache
import com.sap.piper.Utils
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -66,6 +68,14 @@ class SetupCommonPipelineEnvironmentTest extends BasePiperTest {
usedConfigFile = parameters.file
return yamlParser.load(examplePipelineConfig)
})
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,3 +1,4 @@
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -7,6 +8,7 @@ import util.JenkinsLoggingRule
import util.JenkinsReadYamlRule
import util.JenkinsStepRule
import util.Rules
import com.sap.piper.Utils
import static org.junit.Assert.*
@ -26,6 +28,12 @@ class SlackSendNotificationTest extends BasePiperTest {
@Before
void init() throws Exception {
helper.registerAllowedMethod("slackSend", [Map.class], {m -> slackCallMap = m})
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -2,6 +2,7 @@ import static org.hamcrest.Matchers.hasEntry
import static org.hamcrest.Matchers.hasItem
import static org.hamcrest.Matchers.is
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -17,6 +18,7 @@ import util.JenkinsStepRule
import util.JenkinsLoggingRule
import util.Rules
import com.sap.piper.Utils
import com.sap.piper.MapUtils
class SnykExecuteTest extends BasePiperTest {
@ -69,6 +71,13 @@ class SnykExecuteTest extends BasePiperTest {
helper.registerAllowedMethod('archiveArtifacts', [String], {
s -> archiveStepPatterns.push(s.toString())
})
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,3 +1,4 @@
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -5,6 +6,8 @@ import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain
import util.*
import com.sap.piper.Utils
import static org.hamcrest.Matchers.*
import static org.junit.Assert.assertThat
@ -84,6 +87,13 @@ class SpinnakerTriggerPipelineTest extends BasePiperTest {
shellRule.setReturnValue('curl -H \'Content-Type: application/json\' -X POST -d \'{"parameters":{"param1":"val1"}}\' --verbose --cert $clientCertificate --key $clientKey https://spinnakerTest.url/pipelines/spinnakerTestApp/spinnakerTestPipeline', '{"ref": "/testRef"}')
shellRule.setReturnValue('curl -X GET https://spinnakerTest.url/testRef --silent --cert $clientCertificate --key $clientKey', '{"status": "SUCCEEDED"}')
shellRule.setReturnValue('curl -X GET https://spinnakerTest.url/testRef --verbose --cert $clientCertificate --key $clientKey', '{"status": "SUCCEEDED"}')
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,3 +1,4 @@
import org.junit.After
import org.junit.Before
import org.junit.Ignore
import org.junit.Rule
@ -11,6 +12,8 @@ import util.JenkinsStepRule
import static org.junit.Assert.assertEquals
import static org.junit.Assert.assertTrue
import com.sap.piper.Utils
import util.Rules
import minimatch.Minimatch
@ -54,6 +57,13 @@ class TestsPublishResultsTest extends BasePiperTest {
helper.registerAllowedMethod('archiveArtifacts', [Map.class], {
parameters -> archiveStepPatterns.push(parameters.artifacts)
})
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,4 +1,5 @@
import com.sap.piper.JenkinsUtils
import com.sap.piper.Utils
import com.sap.piper.integration.TransportManagementService
import hudson.AbortException
@ -74,10 +75,12 @@ public class TmsUploadTest extends BasePiperTest {
.registerYaml("dummy.mtaext", new FileInputStream(new File("test/resources/TransportManagementService/dummy.mtaext")))
.registerYaml("dummy2.mtaext", new FileInputStream(new File("test/resources/TransportManagementService/dummy2.mtaext")))
.registerYaml("invalidDummy.mtaext", new FileInputStream(new File("test/resources/TransportManagementService/invalidDummy.mtaext")))
Utils.metaClass.echo = { def m -> }
}
@After
void tearDown() {
Utils.metaClass = null
calledTmsMethodsWithArgs.clear()
}

View File

@ -5,6 +5,7 @@ import java.util.Map
import org.hamcrest.Matchers
import org.hamcrest.core.StringContains
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -14,6 +15,7 @@ import org.junit.rules.RuleChain
import com.sap.piper.cm.BackendType
import com.sap.piper.cm.ChangeManagement
import com.sap.piper.cm.ChangeManagementException
import com.sap.piper.Utils
import util.BasePiperTest
import util.JenkinsCredentialsRule
@ -42,6 +44,7 @@ public class TransportRequestCreateTest extends BasePiperTest {
@Before
public void setup() {
Utils.metaClass.echo = { def m -> }
nullScript.commonPipelineEnvironment.configuration = [general:
[changeManagement:
@ -60,6 +63,11 @@ public class TransportRequestCreateTest extends BasePiperTest {
]
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test
public void changeIdNotProvidedSOLANTest() {

View File

@ -2,12 +2,14 @@ import static org.hamcrest.Matchers.allOf
import static org.hamcrest.Matchers.containsString
import org.hamcrest.Matchers
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain
import com.sap.piper.Utils
import com.sap.piper.cm.BackendType
import com.sap.piper.cm.ChangeManagement
import com.sap.piper.cm.ChangeManagementException
@ -50,6 +52,12 @@ public class TransportRequestReleaseTest extends BasePiperTest {
]
]
]
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -5,6 +5,7 @@ import java.util.List
import java.util.Map
import org.hamcrest.Matchers
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -12,6 +13,7 @@ import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain
import com.sap.piper.JenkinsUtils
import com.sap.piper.Utils
import com.sap.piper.cm.BackendType
import com.sap.piper.cm.ChangeManagement
import com.sap.piper.cm.ChangeManagementException
@ -57,6 +59,12 @@ public class TransportRequestUploadFileTest extends BasePiperTest {
]
]
]
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,7 +1,10 @@
import static org.hamcrest.Matchers.*
import com.sap.piper.Utils
import hudson.AbortException
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -72,6 +75,12 @@ class UiVeri5ExecuteTestsTest extends BasePiperTest {
seleniumMap = m
return body()
})
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,3 +1,4 @@
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -16,6 +17,7 @@ import static org.junit.Assert.assertThat
import static org.hamcrest.Matchers.*
import static org.junit.Assert.assertTrue
import static org.junit.Assert.assertFalse
import com.sap.piper.Utils
class WriteTemporaryCredentialsTest extends BasePiperTest {
private JenkinsStepRule stepRule = new JenkinsStepRule(this)
@ -50,6 +52,13 @@ class WriteTemporaryCredentialsTest extends BasePiperTest {
credentialsRule.reset()
.withCredentials('erp-credentials', 'test_user', '********')
.withCredentials('testCred2', 'test_other', '**')
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -10,6 +10,7 @@ import static org.junit.Assert.assertThat
import org.hamcrest.Matchers
import org.hamcrest.core.IsNull
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -17,6 +18,7 @@ import org.junit.rules.ExpectedException
import org.junit.rules.RuleChain
import com.sap.piper.PiperGoUtils
import com.sap.piper.Utils
import hudson.AbortException
import util.BasePiperTest
@ -72,6 +74,13 @@ class XsDeployTest extends BasePiperTest {
shellRule.setReturnValue(JenkinsShellCallRule.Type.REGEX, 'getConfig.* (?!--contextConfig)', '{"mode": "BG_DEPLOY", "action": "NONE", "apiUrl": "https://example.org/xs", "org": "myOrg", "space": "mySpace"}')
nullScript.commonPipelineEnvironment.xsDeploymentId = null
Utils.metaClass.echo = { def m -> }
}
@After
public void tearDown() {
Utils.metaClass = null
}
@Test

View File

@ -1,5 +1,8 @@
package templates
import com.sap.piper.Utils
import org.junit.After
import org.junit.Before
import org.junit.Rule
import org.junit.Test
@ -43,6 +46,13 @@ class PiperPipelineStageIntegrationTest extends BasePiperTest {
helper.registerAllowedMethod('withEnv', [List.class, Closure.class], {env, body ->
body()
})
Utils.metaClass.echo = { m -> }
}
@After
void tearDown() {
Utils.metaClass = null
}
@Test