From c08549263bb88e4aedc98bd43b79ab42b91a3663 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marc=20Mattm=C3=BCller?= Date: Tue, 12 Sep 2023 15:47:36 +0200 Subject: [PATCH] jobs/BuildAll,Common: added time measurement for building targets MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit the nightly builds the target in a loop. To have directly a job log with an overview about the consumed build times, the nightly prints the measured time after each target build. Signed-off-by: Marc Mattmüller --- jobs/Jenkinsfile_BuildAll | 2 ++ jobs/Jenkinsfile_Common | 23 +++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/jobs/Jenkinsfile_BuildAll b/jobs/Jenkinsfile_BuildAll index db9ea77..1a15ac7 100644 --- a/jobs/Jenkinsfile_BuildAll +++ b/jobs/Jenkinsfile_BuildAll @@ -221,6 +221,7 @@ def runBuildJob(commonHelpers, buildTarget, buildBranch) { def buildMachine(commonHelpers, machine, buildBranch) { Boolean isMachineSuccessfullyBuilt = true println "BUILDING ${machine}" + commonHelpers.setupTimeMeasurement() // NOTE: this catchError statement is needed in case of an // abort of the build job or similar failures catchError(buildResult: 'UNSTABLE', stageResult: 'FAILURE') { @@ -235,6 +236,7 @@ def buildMachine(commonHelpers, machine, buildBranch) { if(!isMachineSuccessfullyBuilt) { println "Failed building properly machine ${machine}" } + commonHelpers.printMeasuredTimeToNow("building ${machine}") return isMachineSuccessfullyBuilt } //----------------------------------------------------------------------------- diff --git a/jobs/Jenkinsfile_Common b/jobs/Jenkinsfile_Common index cbb21c5..d225a99 100644 --- a/jobs/Jenkinsfile_Common +++ b/jobs/Jenkinsfile_Common @@ -100,6 +100,29 @@ def getNginxCredentialID() { } +//----------------------------------------------------------------------------- +def getCurrentUtcEpochTime() { + def currTimeUtc = sh(returnStdout: true, script: "bash -c \"date -u +%s\"").trim() + return currTimeUtc +} +//----------------------------------------------------------------------------- +def setupTimeMeasurement() { + env.START_TIME = getCurrentUtcEpochTime() +} +//----------------------------------------------------------------------------- +def getMeasuredTime() { + Integer t_now = Integer.parseInt(getCurrentUtcEpochTime()) + Integer t_start = Integer.parseInt("${env.START_TIME}") + Integer timeDiffS = (t_now - t_start) + return timeDiffS +} +//----------------------------------------------------------------------------- +def printMeasuredTimeToNow(timeDescriptor) { + measTimeS = getMeasuredTime() + println "Measured time for ${timeDescriptor} [s] = " + measTimeS +} + + //----------------------------------------------------------------------------- def setupGlobalEnvironmentVariables(repoDir, machine) { env.MACHINE = "${machine}"