mirror of
https://github.com/SAP/jenkins-library.git
synced 2026-06-19 22:58:55 +02:00
Merge remote-tracking branch 'github/master' into HEAD
This commit is contained in:
@@ -55,6 +55,7 @@ def stashWithMessage(name, msg, include = '**/*.*', exclude = '') {
|
||||
}
|
||||
|
||||
def unstash(name, msg = "Unstash failed:") {
|
||||
|
||||
def unstashedContent = []
|
||||
try {
|
||||
echo "Unstash content: ${name}"
|
||||
@@ -70,7 +71,9 @@ def unstashAll(stashContent) {
|
||||
def unstashedContent = []
|
||||
if (stashContent) {
|
||||
for (i = 0; i < stashContent.size(); i++) {
|
||||
unstashedContent += unstash(stashContent[i])
|
||||
if(stashContent[i]) {
|
||||
unstashedContent += unstash(stashContent[i])
|
||||
}
|
||||
}
|
||||
}
|
||||
return unstashedContent
|
||||
|
||||
@@ -38,6 +38,7 @@ class UtilsTest extends BasePiperTest {
|
||||
void setup() {
|
||||
|
||||
parameters = [:]
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -70,4 +71,11 @@ class UtilsTest extends BasePiperTest {
|
||||
// generated with "echo -n 'ContinuousDelivery' | sha1sum | sed 's/ -//'"
|
||||
assertThat(result, is('0dad6c33b6246702132454f604dee80740f399ad'))
|
||||
}
|
||||
|
||||
@Test
|
||||
void testUnstashAllSkipNull() {
|
||||
|
||||
def stashResult = utils.unstashAll(['a', null, 'b'])
|
||||
assert stashResult == ['a', 'b']
|
||||
}
|
||||
}
|
||||
|
||||
@@ -16,19 +16,30 @@ void call(Map parameters = [:], body) {
|
||||
echo "--- Begin library step of: ${stepName} ---"
|
||||
|
||||
body()
|
||||
} catch (Throwable err) {
|
||||
} catch (Throwable error) {
|
||||
if (verbose)
|
||||
message += SimpleTemplateEngine.newInstance()
|
||||
.createTemplate(libraryResource('com.sap.piper/templates/error.log'))
|
||||
.make([
|
||||
stepName: stepName,
|
||||
stepParameters: stepParameters?.toString(),
|
||||
error: err
|
||||
error: error
|
||||
]).toString()
|
||||
throw err
|
||||
writeErrorToInfluxData(parameters, error)
|
||||
throw error
|
||||
} finally {
|
||||
if (verbose)
|
||||
message += "--- End library step of: ${stepName} ---"
|
||||
echo message
|
||||
}
|
||||
}
|
||||
|
||||
private void writeErrorToInfluxData(config, error){
|
||||
def script = config?.stepParameters?.script
|
||||
|
||||
if(script && script.commonPipelineEnvironment?.getInfluxCustomDataMapTags().build_error_message == null){
|
||||
script.commonPipelineEnvironment?.setInfluxCustomDataMapTagsEntry('pipeline_data', 'build_error_step', config.stepName)
|
||||
script.commonPipelineEnvironment?.setInfluxCustomDataMapTagsEntry('pipeline_data', 'build_error_stage', script.env?.STAGE_NAME)
|
||||
script.commonPipelineEnvironment?.setInfluxCustomDataMapEntry('pipeline_data', 'build_error_message', error.getMessage())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user