From a3e1d84566270ae09681e7e33f191f911d13ec03 Mon Sep 17 00:00:00 2001 From: evanchia Date: Wed, 21 Apr 2021 10:54:26 -0700 Subject: [PATCH 1/3] Test metrics uses both Jenkins endpoints fix --- scripts/build/Jenkins/Jenkinsfile | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index 662ddc7454..4f4708aea3 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -349,6 +349,18 @@ def Build(Map options, String platform, String type, String workspace) { } } +def getJenkinsBaseUrl() { + def job_url = new URL(env.JOB_URL) + + // Return a new URL using the protocol, host and port only. + return new URL( + job_url.getProtocol(), + job_url.getHost(), + job_url.getPort(), + '' + ).toString() +} + def TestMetrics(Map options, String workspace, String branchName, String repoName, String buildJobName, String outputDirectory, String configuration) { catchError(buildResult: null, stageResult: null) { def cmakeBuildDir = [workspace, ENGINE_REPOSITORY_NAME, outputDirectory].join('/') @@ -360,7 +372,11 @@ def TestMetrics(Map options, String workspace, String branchName, String repoNam userRemoteConfigs: [[url: "${env.MARS_REPO}", name: 'mars', credentialsId: "${env.GITHUB_USER}"]] ] withCredentials([usernamePassword(credentialsId: "${env.SERVICE_USER}", passwordVariable: 'apitoken', usernameVariable: 'username')]) { - def command = "${options.PYTHON_DIR}/python.cmd -u mars/scripts/python/ctest_test_metric_scraper.py -e jenkins.creds.user ${username} -e jenkins.creds.pass ${apitoken} ${cmakeBuildDir} ${branchName} %BUILD_NUMBER% AR ${configuration} ${repoName} " + def jenkins_url = getJenkinsBaseUrl() + def command = "${options.PYTHON_DIR}/python.cmd -u mars/scripts/python/ctest_test_metric_scraper.py" + + "-e jenkins.creds.user ${username} -e jenkins.creds.pass ${apitoken} " + + "-e jenkins.base_url ${jenkins_url}" + + "${cmakeBuildDir} ${branchName} %BUILD_NUMBER% AR ${configuration} ${repoName} " bat label: "Publishing ${buildJobName} Test Metrics", script: command } From 7bfde0ddba9d025ee401e0d8362c1868f64d7ff1 Mon Sep 17 00:00:00 2001 From: evanchia Date: Wed, 21 Apr 2021 12:45:14 -0700 Subject: [PATCH 2/3] Using jenkins env var instead of extracting function --- scripts/build/Jenkins/Jenkinsfile | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index 4f4708aea3..cdb7874231 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -349,18 +349,6 @@ def Build(Map options, String platform, String type, String workspace) { } } -def getJenkinsBaseUrl() { - def job_url = new URL(env.JOB_URL) - - // Return a new URL using the protocol, host and port only. - return new URL( - job_url.getProtocol(), - job_url.getHost(), - job_url.getPort(), - '' - ).toString() -} - def TestMetrics(Map options, String workspace, String branchName, String repoName, String buildJobName, String outputDirectory, String configuration) { catchError(buildResult: null, stageResult: null) { def cmakeBuildDir = [workspace, ENGINE_REPOSITORY_NAME, outputDirectory].join('/') @@ -372,10 +360,9 @@ def TestMetrics(Map options, String workspace, String branchName, String repoNam userRemoteConfigs: [[url: "${env.MARS_REPO}", name: 'mars', credentialsId: "${env.GITHUB_USER}"]] ] withCredentials([usernamePassword(credentialsId: "${env.SERVICE_USER}", passwordVariable: 'apitoken', usernameVariable: 'username')]) { - def jenkins_url = getJenkinsBaseUrl() def command = "${options.PYTHON_DIR}/python.cmd -u mars/scripts/python/ctest_test_metric_scraper.py" + "-e jenkins.creds.user ${username} -e jenkins.creds.pass ${apitoken} " + - "-e jenkins.base_url ${jenkins_url}" + + "-e jenkins.base_url ${env.JENKINS_URL}" + "${cmakeBuildDir} ${branchName} %BUILD_NUMBER% AR ${configuration} ${repoName} " bat label: "Publishing ${buildJobName} Test Metrics", script: command From efacc3c8bb69a5c3836d0711752129ab10a5453d Mon Sep 17 00:00:00 2001 From: evanchia Date: Wed, 21 Apr 2021 13:28:12 -0700 Subject: [PATCH 3/3] Adding missing spaces in test metrics command string --- scripts/build/Jenkins/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index cdb7874231..4352cb1e6a 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -360,9 +360,9 @@ def TestMetrics(Map options, String workspace, String branchName, String repoNam userRemoteConfigs: [[url: "${env.MARS_REPO}", name: 'mars', credentialsId: "${env.GITHUB_USER}"]] ] withCredentials([usernamePassword(credentialsId: "${env.SERVICE_USER}", passwordVariable: 'apitoken', usernameVariable: 'username')]) { - def command = "${options.PYTHON_DIR}/python.cmd -u mars/scripts/python/ctest_test_metric_scraper.py" + + def command = "${options.PYTHON_DIR}/python.cmd -u mars/scripts/python/ctest_test_metric_scraper.py " + "-e jenkins.creds.user ${username} -e jenkins.creds.pass ${apitoken} " + - "-e jenkins.base_url ${env.JENKINS_URL}" + + "-e jenkins.base_url ${env.JENKINS_URL} " + "${cmakeBuildDir} ${branchName} %BUILD_NUMBER% AR ${configuration} ${repoName} " bat label: "Publishing ${buildJobName} Test Metrics", script: command