1
0
mirror of https://github.com/SAP/jenkins-library.git synced 2025-03-03 15:02:35 +02:00

dockerExecuteOnKubernetes - hide sensitive information (#733)

* dockerExecuteOnKubernetes - hide yaml by default
* hide step parameters to not leak sensitive parameter values into the log
* add more details to log output
This commit is contained in:
Oliver Nocon 2019-06-26 08:38:47 +02:00 committed by GitHub
parent 9330b34bb6
commit 3e46254701
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 4 deletions

View File

@ -79,7 +79,7 @@ class HandlePipelineStepErrorsTest extends BasePiperTest {
// asserts
assertThat(isReported, is(true))
assertThat(loggingRule.log, containsString('--- An error occurred in the library step: testStep'))
assertThat(loggingRule.log, containsString('[something:anything]'))
assertThat(loggingRule.log, containsString('to show step parameters, set verbose:true'))
}
}

View File

@ -14,7 +14,12 @@ import hudson.AbortException
@Field def PLUGIN_ID_KUBERNETES = 'kubernetes'
@Field Set GENERAL_CONFIG_KEYS = [
'jenkinsKubernetes'
'jenkinsKubernetes',
/**
* Print more detailed information into the log.
* @possibleValues `true`, `false`
*/
'verbose'
]
@Field Set STEP_CONFIG_KEYS = GENERAL_CONFIG_KEYS.plus([
/**
@ -152,7 +157,9 @@ def getOptions(config) {
if (config.nodeSelector) {
options.nodeSelector = config.nodeSelector
}
if (!config.verbose) {
options.showRawYaml = false
}
return options
}

View File

@ -119,7 +119,7 @@ private String formatErrorMessage(Map config, error){
libraryDocumentationUrl: config.libraryDocumentationUrl,
libraryRepositoryUrl: config.libraryRepositoryUrl,
stepName: config.stepName,
stepParameters: config.stepParameters?.toString()
stepParameters: (config.stepParameters?.verbose == true) ? config.stepParameters?.toString() : '*** to show step parameters, set verbose:true in general pipeline configuration\n*** WARNING: this may reveal sensitive information. ***'
]
return SimpleTemplateEngine
.newInstance()