mirror of
https://github.com/SAP/jenkins-library.git
synced 2025-03-03 15:02:35 +02:00
fix(telemetry): disable telemetry in init stage (#1272)
* disable telemetry in init stage * Apply suggestions from code review * Update vars/piperStageWrapper.groovy
This commit is contained in:
parent
289bb58e66
commit
6feb0cf9e9
@ -46,7 +46,7 @@ void call(Map parameters = [:]) {
|
||||
|
||||
def stageName = parameters.stageName?:env.STAGE_NAME
|
||||
|
||||
piperStageWrapper (script: script, stageName: stageName, stashContent: [], ordinal: 1) {
|
||||
piperStageWrapper (script: script, stageName: stageName, stashContent: [], ordinal: 1, telemetryDisabled: true) {
|
||||
def scmInfo = checkout scm
|
||||
|
||||
setupCommonPipelineEnvironment script: script, customDefaults: parameters.customDefaults
|
||||
|
@ -37,12 +37,12 @@ void call(Map parameters = [:], body) {
|
||||
DebugReport.instance.environment.put("environment", "Kubernetes")
|
||||
withEnv(["POD_NAME=${stageName}"]) {
|
||||
dockerExecuteOnKubernetes(script: script, containerMap: containerMap, stageName: stageName) {
|
||||
executeStage(script, body, stageName, config, utils)
|
||||
executeStage(script, body, stageName, config, utils, parameters.telemetryDisabled)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
node(config.nodeLabel) {
|
||||
executeStage(script, body, stageName, config, utils)
|
||||
executeStage(script, body, stageName, config, utils, parameters.telemetryDisabled)
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -60,7 +60,7 @@ private void stageLocking(Map config, Closure body) {
|
||||
}
|
||||
}
|
||||
|
||||
private void executeStage(script, originalStage, stageName, config, utils) {
|
||||
private void executeStage(script, originalStage, stageName, config, utils, telemetryDisabled = false) {
|
||||
boolean projectExtensions
|
||||
boolean globalExtensions
|
||||
def startTime = System.currentTimeMillis()
|
||||
@ -124,26 +124,29 @@ private void executeStage(script, originalStage, stageName, config, utils) {
|
||||
//Perform stashing of selected files in workspace
|
||||
utils.stashStageFiles(script, stageName)
|
||||
|
||||
def duration = System.currentTimeMillis() - startTime
|
||||
utils.pushToSWA([
|
||||
eventType: 'library-os-stage',
|
||||
stageName: stageName,
|
||||
stepParamKey1: 'buildResult',
|
||||
stepParam1: "${script.currentBuild.currentResult}",
|
||||
buildResult: "${script.currentBuild.currentResult}",
|
||||
stepParamKey2: 'stageStartTime',
|
||||
stepParam2: "${startTime}",
|
||||
stageStartTime: "${startTime}",
|
||||
stepParamKey3: 'stageDuration',
|
||||
stepParam3: "${duration}",
|
||||
stageDuration: "${duration}",
|
||||
stepParamKey4: 'projectExtension',
|
||||
stepParam4: "${projectExtensions}",
|
||||
projectExtension: "${projectExtensions}",
|
||||
stepParamKey5: 'globalExtension',
|
||||
stepParam5: "${globalExtensions}",
|
||||
globalExtension: "${globalExtensions}"
|
||||
], config)
|
||||
// In general telemetry reporting is disabled by the config settings. This flag is used to disable the reporting when the config is not yet read (e.g. init stage).
|
||||
if(!telemetryDisabled){
|
||||
def duration = System.currentTimeMillis() - startTime
|
||||
utils.pushToSWA([
|
||||
eventType: 'library-os-stage',
|
||||
stageName: stageName,
|
||||
stepParamKey1: 'buildResult',
|
||||
stepParam1: "${script.currentBuild.currentResult}",
|
||||
buildResult: "${script.currentBuild.currentResult}",
|
||||
stepParamKey2: 'stageStartTime',
|
||||
stepParam2: "${startTime}",
|
||||
stageStartTime: "${startTime}",
|
||||
stepParamKey3: 'stageDuration',
|
||||
stepParam3: "${duration}",
|
||||
stageDuration: "${duration}",
|
||||
stepParamKey4: 'projectExtension',
|
||||
stepParam4: "${projectExtensions}",
|
||||
projectExtension: "${projectExtensions}",
|
||||
stepParamKey5: 'globalExtension',
|
||||
stepParam5: "${globalExtensions}",
|
||||
globalExtension: "${globalExtensions}"
|
||||
], config)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user