From c507422760997dd035d24a29ce553dc33ff628d1 Mon Sep 17 00:00:00 2001 From: scottr Date: Fri, 18 Jun 2021 20:52:04 -0700 Subject: [PATCH] [cpack/jenkins-main] update build url tag generation to use existing env vars from Jenkins --- scripts/build/Jenkins/Jenkinsfile | 6 +++++ .../build/Platform/Windows/build_config.json | 6 ++--- .../Windows/build_installer_windows.cmd | 2 +- .../Platform/Windows/installer_windows.cmd | 26 ++++++++++--------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index 693cf31727..295c92e4ab 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -256,6 +256,12 @@ def CheckoutRepo(boolean disableSubmodules = false) { env.CHANGE_ID = readFile file: 'commitid' env.CHANGE_ID = env.CHANGE_ID.trim() palRm('commitid') + + // CHANGE_DATE is used by the installer to provide some ability to sort tagged builds in addition to BRANCH_NAME and CHANGE_ID + palSh("git show -s --format=\"%cs\" ${env.CHANGE_ID} > commitdate", 'Getting commit date') + env.CHANGE_DATE = readFile file: 'commitdate' + env.CHANGE_DATE = env.CHANGE_DATE.trim() + palRm('commitdate') } def PreBuildCommonSteps(Map pipelineConfig, String repositoryName, String projectName, String pipeline, String branchName, String platform, String buildType, String workspace, boolean mount = true, boolean disableSubmodules = false) { diff --git a/scripts/build/Platform/Windows/build_config.json b/scripts/build/Platform/Windows/build_config.json index 674d6c11bd..c13c6939a7 100644 --- a/scripts/build/Platform/Windows/build_config.json +++ b/scripts/build/Platform/Windows/build_config.json @@ -316,12 +316,10 @@ "OUTPUT_DIRECTORY": "build\\windows_vs2019", "CMAKE_OPTIONS": "-G \"Visual Studio 16 2019\" -DCMAKE_SYSTEM_VERSION=10.0 -DLY_UNITY_BUILD=TRUE -DLY_DISABLE_TEST_MODULES=TRUE", "EXTRA_CMAKE_OPTIONS": "-DCPACK_WIX_ROOT=\"!WIX! \" -DLY_INSTALLER_DOWNLOAD_URL=https://dkb1uj4hs9ikv.cloudfront.net -DLY_INSTALLER_LICENSE_URL=https://example.com", - "BUILD_TYPE": "staging", - "BUILD_ID": "spectra-prism", + "CPACK_BUCKET": "spectra-prism-staging-us-west-2", "CMAKE_LY_PROJECTS": "", "CMAKE_TARGET": "ALL_BUILD", - "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo", - "REGION": "us-west-2" + "CMAKE_NATIVE_BUILD_ARGS": "/m /nologo" } }, "project_enginesource_profile_vs2019": { diff --git a/scripts/build/Platform/Windows/build_installer_windows.cmd b/scripts/build/Platform/Windows/build_installer_windows.cmd index beada918dc..5d1408bd60 100644 --- a/scripts/build/Platform/Windows/build_installer_windows.cmd +++ b/scripts/build/Platform/Windows/build_installer_windows.cmd @@ -10,7 +10,7 @@ REM remove or modify any license notices. This file is distributed on an "AS IS" REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. REM -set "LY_INSTALLER_UPLOAD_URL=s3://%BUILD_ID%-%BUILD_TYPE%-%REGION%" +SET "LY_INSTALLER_UPLOAD_URL=s3://%CPACK_BUCKET%" CALL "%~dp0build_windows.cmd" IF NOT %ERRORLEVEL%==0 GOTO :error diff --git a/scripts/build/Platform/Windows/installer_windows.cmd b/scripts/build/Platform/Windows/installer_windows.cmd index 5caf8b7b80..5deb4f931d 100644 --- a/scripts/build/Platform/Windows/installer_windows.cmd +++ b/scripts/build/Platform/Windows/installer_windows.cmd @@ -50,21 +50,23 @@ IF ERRORLEVEL 1 ( GOTO :popd_error ) -REM generate the build ID for artifact upload tagging -PUSHD "%~dp0/../../../.." -SET "ENGINE_ROOT=%cd%" -POPD +REM use the git info to generate an identifier used by the online installer urls +SET "BUILD_ID_FILE=_CPack\\build_id.txt" -SET "GEN_BUILD_ID_SCRIPT=%ENGINE_ROOT%/scripts/build/tools/generate_build_tag.py" -SET "BUILD_ID_FILE=_CPack/build_id.txt" - -ECHO [ci_build] "%ENGINE_ROOT%/python/python.cmd" -u "%GEN_BUILD_ID_SCRIPT%" "%BUILD_ID_FILE%" -CALL "%ENGINE_ROOT%/python/python.cmd" -u "%GEN_BUILD_ID_SCRIPT%" "%BUILD_ID_FILE%" -IF ERRORLEVEL 1 ( - ECHO [ci_build] Failed to generate build ID - GOTO :popd_error +SET BRANCH_ID="" +REM limit branch separators to 6 +FOR /F "tokens=1-6 delims=/" %%a in ("!BRANCH_NAME!") DO ( + SET BRANCH_ID=%%a + if NOT "%%b"=="" SET BRANCH_ID=!BRANCH_ID!-%%b + if NOT "%%c"=="" SET BRANCH_ID=!BRANCH_ID!-%%c + if NOT "%%d"=="" SET BRANCH_ID=!BRANCH_ID!-%%d + if NOT "%%e"=="" SET BRANCH_ID=!BRANCH_ID!-%%e + if NOT "%%f"=="" SET BRANCH_ID=!BRANCH_ID!-%%f ) +REM write out the build ID to disk so cpack can consume it +ECHO %BRANCH_ID%/%CHANGE_DATE%-%CHANGE_ID:~0,7% > "%BUILD_ID_FILE%" + ECHO [ci_build] "!CPACK_PATH!" -C %CONFIGURATION% "!CPACK_PATH!" -C %CONFIGURATION% IF NOT %ERRORLEVEL%==0 (