Fixes for Test Screenshot upload build step (#4792)

Fixes the test screenshot upload build step:

- Added missing positional parameters
- Double quoting the command statements to allow variable expansion (also fixes broken Python call)
- Escaping the double quotes within the command statement

Signed-off-by: Mike Chang <changml@amazon.com>
monroegm-disable-blank-issue-2
Mike Chang 4 years ago committed by GitHub
parent 1474cfdcbf
commit 8ab1cfacf5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -416,16 +416,18 @@ def ExportTestResults(Map options, String platform, String type, String workspac
} }
} }
def ExportTestScreenshots(Map options, String workspace, String platformName, String jobName, Map params) { def ExportTestScreenshots(Map options, String branchName, String platformName, String jobName, String workspace, Map params) {
catchError(message: "Error exporting test screenshots (this won't fail the build)", buildResult: 'SUCCESS', stageResult: 'FAILURE') { catchError(message: "Error exporting test screenshots (this won't fail the build)", buildResult: 'SUCCESS', stageResult: 'FAILURE') {
def screenshotsFolder = '${workspace}/${ENGINE_REPOSITORY_NAME}/AutomatedTesting/user/PythonTests/Automated/Screenshots' dir("${workspace}/${ENGINE_REPOSITORY_NAME}") {
def s3Uploader = '${workspace}/${ENGINE_REPOSITORY_NAME}/scripts/build/tools/upload_to_s3.py' def screenshotsFolder = "AutomatedTesting/user/PythonTests/Automated/Screenshots"
def command = '${options.PYTHON_DIR}/python.cmd -u ${s3Uploader} --base_dir ${screenshotsFolder} ' + def s3Uploader = "scripts/build/tools/upload_to_s3.py"
'--file_regex "(.*zip$)" --bucket ${env.TEST_SCREENSHOT_BUCKET} ' + def command = "${options.PYTHON_DIR}/python.cmd -u ${s3Uploader} --base_dir ${screenshotsFolder} " +
'--search_subdirectories True --key_prefix ${branchName}_${env.BUILD_NUMBER}' + '--file_regex \\"(.*zip\$)\\" ' +
'--extra-args {"ACL": "bucket-owner-full-control"}' "--bucket ${env.TEST_SCREENSHOT_BUCKET} " +
bat label: "Uploading test screenshots for ${jobName}", "--search_subdirectories True --key_prefix ${branchName}_${env.BUILD_NUMBER} " +
script: command '--extra_args {\\"ACL\\":\\"bucket-owner-full-control\\"}'
palSh(command, "Uploading test screenshots for ${jobName}")
}
} }
} }
@ -484,10 +486,10 @@ def CreateExportTestResultsStage(Map pipelineConfig, String platformName, String
} }
} }
def CreateExportTestScreenshotsStage(Map pipelineConfig, String platformName, String jobName, Map environmentVars, Map params) { def CreateExportTestScreenshotsStage(Map pipelineConfig, String branchName, String platformName, String jobName, Map environmentVars, Map params) {
return { return {
stage("${jobName}_screenshots") { stage("${jobName}_screenshots") {
ExportTestScreenshots(pipelineConfig, platformName, jobName, environmentVars['WORKSPACE'], params) ExportTestScreenshots(pipelineConfig, branchName, platformName, jobName, environmentVars['WORKSPACE'], params)
} }
} }
} }
@ -556,7 +558,7 @@ def CreateSingleNode(Map pipelineConfig, def platform, def build_job, Map envVar
CreateExportTestResultsStage(pipelineConfig, platform.key, build_job_name, envVars, params).call() CreateExportTestResultsStage(pipelineConfig, platform.key, build_job_name, envVars, params).call()
} }
if (params && params.containsKey('TEST_SCREENSHOTS') && params.TEST_SCREENSHOTS == 'True' && currentResult == 'FAILURE') { if (params && params.containsKey('TEST_SCREENSHOTS') && params.TEST_SCREENSHOTS == 'True' && currentResult == 'FAILURE') {
CreateExportTestScreenshotsStage(pipelineConfig, platform.key, build_job_name, envVars, params).call() CreateExportTestScreenshotsStage(pipelineConfig, branchName, platform.key, build_job_name, envVars, params).call()
} }
CreateTeardownStage(envVars).call() CreateTeardownStage(envVars).call()
} }

Loading…
Cancel
Save