From 78b8daa783dac2a2418ef600e3d0912993f36872 Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Wed, 23 Jun 2021 08:01:39 -0700 Subject: [PATCH] LYN-4745 ci_build_metrics doesnt distinguish between different repo (#1496) * add repository to ci_build_metrics * fixing build * changing the job to pass the right parameters * passing parameters that need to be expanded * missed this, important * fixing typo --- scripts/build/Jenkins/Jenkinsfile | 3 ++- scripts/build/Platform/Android/build_config.json | 2 +- scripts/build/Platform/Linux/build_config.json | 2 +- scripts/build/Platform/Linux/python_linux.sh | 4 ++-- scripts/build/Platform/Mac/build_config.json | 2 +- scripts/build/Platform/Mac/python_mac.sh | 4 ++-- scripts/build/Platform/Windows/build_config.json | 2 +- scripts/build/Platform/iOS/build_config.json | 2 +- scripts/build/ci_build_metrics.py | 6 +++++- 9 files changed, 16 insertions(+), 11 deletions(-) diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index 7bb26fdf8c..7afc17348d 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -458,6 +458,7 @@ try { repositoryUrl = scm.getUserRemoteConfigs()[0].getUrl() // repositoryName is the full repository name repositoryName = (repositoryUrl =~ /https:\/\/github.com\/(.*)\.git/)[0][1] + env.REPOSITORY_NAME = repositoryName (projectName, pipelineName) = GetRunningPipelineName(env.JOB_NAME) // env.JOB_NAME is the name of the job given by Jenkins if(env.BRANCH_NAME) { @@ -468,7 +469,7 @@ try { } pipelineProperties.add(disableConcurrentBuilds()) - echo "Running \"${pipelineName}\" for \"${branchName}\"..." + echo "Running repository: \"${repositoryName}\", pipeline: \"${pipelineName}\", branch: \"${branchName}\"..." CheckoutBootstrapScripts(branchName) diff --git a/scripts/build/Platform/Android/build_config.json b/scripts/build/Platform/Android/build_config.json index 33248ffe26..c1fbb1dd87 100644 --- a/scripts/build/Platform/Android/build_config.json +++ b/scripts/build/Platform/Android/build_config.json @@ -22,7 +22,7 @@ "COMMAND":"../Windows/python_windows.cmd", "PARAMETERS": { "SCRIPT_PATH":"scripts/build/ci_build_metrics.py", - "SCRIPT_PARAMETERS":"--platform Android --jobname \"!JOB_NAME!\" --jobnumber \"!BUILD_NUMBER!\" --jobnode \"!NODE_NAME!\" --changelist \"!CHANGE_ID!\"" + "SCRIPT_PARAMETERS":"--platform=Android --repository=!REPOSITORY_NAME! --jobname=!JOB_NAME! --jobnumber=!BUILD_NUMBER! --jobnode=!NODE_LABEL! --changelist=!CHANGE_ID!" } }, "debug": { diff --git a/scripts/build/Platform/Linux/build_config.json b/scripts/build/Platform/Linux/build_config.json index 9baa4d6702..a3b249d476 100644 --- a/scripts/build/Platform/Linux/build_config.json +++ b/scripts/build/Platform/Linux/build_config.json @@ -24,7 +24,7 @@ "COMMAND": "python_linux.sh", "PARAMETERS": { "SCRIPT_PATH": "scripts/build/ci_build_metrics.py", - "SCRIPT_PARAMETERS": "--platform Linux --jobname '${JOB_NAME}' --jobnumber '${BUILD_NUMBER}' --jobnode '${NODE_NAME}' --changelist '${CHANGE_ID}'" + "SCRIPT_PARAMETERS": "--platform=Linux --repository=${REPOSITORY_NAME} --jobname=${JOB_NAME} --jobnumber=${BUILD_NUMBER} --jobnode=${NODE_LABEL} --changelist=${CHANGE_ID}" } }, "debug": { diff --git a/scripts/build/Platform/Linux/python_linux.sh b/scripts/build/Platform/Linux/python_linux.sh index 6e1bd73b36..0fe205fcc2 100755 --- a/scripts/build/Platform/Linux/python_linux.sh +++ b/scripts/build/Platform/Linux/python_linux.sh @@ -12,5 +12,5 @@ set -o errexit # exit on the first failure encountered -echo [ci_build] python/python.sh -u ${SCRIPT_PATH} ${SCRIPT_PARAMETERS} -python/python.sh -u ${SCRIPT_PATH} ${SCRIPT_PARAMETERS} \ No newline at end of file +echo [ci_build] python/python.sh -u ${SCRIPT_PATH} $(eval echo ${SCRIPT_PARAMETERS}) +python/python.sh -u ${SCRIPT_PATH} $(eval echo ${SCRIPT_PARAMETERS}) \ No newline at end of file diff --git a/scripts/build/Platform/Mac/build_config.json b/scripts/build/Platform/Mac/build_config.json index 971e5e47a1..2cf445a836 100644 --- a/scripts/build/Platform/Mac/build_config.json +++ b/scripts/build/Platform/Mac/build_config.json @@ -24,7 +24,7 @@ "COMMAND": "python_mac.sh", "PARAMETERS": { "SCRIPT_PATH": "scripts/build/ci_build_metrics.py", - "SCRIPT_PARAMETERS": "--platform Mac --jobname '${JOB_NAME}' --jobnumber '${BUILD_NUMBER}' --jobnode '${NODE_NAME}' --changelist '${CHANGE_ID}'" + "SCRIPT_PARAMETERS": "--platform=Mac --repository=${REPOSITORY_NAME} --jobname=${JOB_NAME} --jobnumber=${BUILD_NUMBER} --jobnode=${NODE_LABEL} --changelist=${CHANGE_ID}" } }, "debug": { diff --git a/scripts/build/Platform/Mac/python_mac.sh b/scripts/build/Platform/Mac/python_mac.sh index 6e1bd73b36..0fe205fcc2 100755 --- a/scripts/build/Platform/Mac/python_mac.sh +++ b/scripts/build/Platform/Mac/python_mac.sh @@ -12,5 +12,5 @@ set -o errexit # exit on the first failure encountered -echo [ci_build] python/python.sh -u ${SCRIPT_PATH} ${SCRIPT_PARAMETERS} -python/python.sh -u ${SCRIPT_PATH} ${SCRIPT_PARAMETERS} \ No newline at end of file +echo [ci_build] python/python.sh -u ${SCRIPT_PATH} $(eval echo ${SCRIPT_PARAMETERS}) +python/python.sh -u ${SCRIPT_PATH} $(eval echo ${SCRIPT_PARAMETERS}) \ No newline at end of file diff --git a/scripts/build/Platform/Windows/build_config.json b/scripts/build/Platform/Windows/build_config.json index 45cea2b5d8..c16e9a5dbe 100644 --- a/scripts/build/Platform/Windows/build_config.json +++ b/scripts/build/Platform/Windows/build_config.json @@ -56,7 +56,7 @@ "COMMAND": "python_windows.cmd", "PARAMETERS": { "SCRIPT_PATH": "scripts/build/ci_build_metrics.py", - "SCRIPT_PARAMETERS": "--platform Windows --jobname \"!JOB_NAME!\" --jobnumber \"!BUILD_NUMBER!\" --jobnode \"!NODE_NAME!\" --changelist \"!CHANGE_ID!\"" + "SCRIPT_PARAMETERS": "--platform=Windows --repository=!REPOSITORY_NAME! --jobname=!JOB_NAME! --jobnumber=!BUILD_NUMBER! --jobnode=!NODE_LABEL! --changelist=!CHANGE_ID!" } }, "windows_packaging_all": { diff --git a/scripts/build/Platform/iOS/build_config.json b/scripts/build/Platform/iOS/build_config.json index 2d9c57f6ee..062ba09630 100644 --- a/scripts/build/Platform/iOS/build_config.json +++ b/scripts/build/Platform/iOS/build_config.json @@ -14,7 +14,7 @@ "COMMAND": "../Mac/python_mac.sh", "PARAMETERS": { "SCRIPT_PATH": "scripts/build/ci_build_metrics.py", - "SCRIPT_PARAMETERS": "--platform iOS --jobname '${JOB_NAME}' --jobnumber '${BUILD_NUMBER}' --jobnode '${NODE_NAME}' --changelist '${CHANGE_ID}'" + "SCRIPT_PARAMETERS": "--platform=iOS --repository=${REPOSITORY_NAME} --jobname=${JOB_NAME} --jobnumber=${BUILD_NUMBER} --jobnode=${NODE_LABEL} --changelist=${CHANGE_ID}" } }, "debug": { diff --git a/scripts/build/ci_build_metrics.py b/scripts/build/ci_build_metrics.py index b732429948..4451725502 100755 --- a/scripts/build/ci_build_metrics.py +++ b/scripts/build/ci_build_metrics.py @@ -38,6 +38,7 @@ def parse_args(): cur_dir = os.path.dirname(os.path.abspath(__file__)) parser = argparse.ArgumentParser() parser.add_argument('-p', '--platform', dest="platform", help="Platform to gather metrics for") + parser.add_argument('-r', '--repository', dest="repository", help="Repository to gather metrics for") parser.add_argument('-a', '--jobname', dest="jobname", default="unknown", help="Name/tag of the job in the CI system (used to track where the report comes from, constant through multiple runs)") parser.add_argument('-u', '--jobnumber', dest="jobnumber", default=-1, help="Number of run in the CI system (used to track where the report comes from, variable through runs)") parser.add_argument('-o', '--jobnode', dest="jobnode", default="unknown", help="Build node name (used to track where the build happened in CI systems where the same jobs run in different hosts)") @@ -211,6 +212,7 @@ def prepare_metrics(args, build_metrics): 'changelist': args.changelist, 'job': {'name': args.jobname, 'number': args.jobnumber, 'node': args.jobnode}, 'platform': args.platform, + 'repository': args.repository, 'build_types': build_metrics, 'timestamp': timestamp.strftime("%Y-%m-%dT%H:%M:%S") } @@ -240,6 +242,7 @@ def submit_report_document(report_file): 'changelist': report_json['changelist'], 'job': report_json['job'], 'platform': report_json['platform'], + 'repository': report_json['repository'], 'type': build_type['build_type'], 'result': int(build_type['result']) or int(build_metric['result']), 'reason': build_type['reason'], @@ -259,8 +262,9 @@ def submit_report_document(report_file): if __name__ == "__main__": args = parse_args() - print(f"[ci_build_metrics] Generatic build metrics for:" + print(f"[ci_build_metrics] Generating build metrics for:" f"\n\tPlatform: {args.platform}" + f"\n\tRepository: {args.repository}" f"\n\tJob Name: {args.jobname}" f"\n\tJob Number: {args.jobnumber}" f"\n\tJob Node: {args.jobnode}"