From 342b81c1848af2df614e244dcdc24d9486d6dd63 Mon Sep 17 00:00:00 2001 From: Michael Delva Date: Mon, 16 Mar 2026 11:22:14 +0100 Subject: [PATCH 1/6] Call setup.ps1 in the unreal feature when needed --- src/generator/templates/unreal.mako | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/src/generator/templates/unreal.mako b/src/generator/templates/unreal.mako index 7e0daa4..7d17870 100644 --- a/src/generator/templates/unreal.mako +++ b/src/generator/templates/unreal.mako @@ -102,7 +102,7 @@ def cleanup() { projectCheckout() stage ( "Cleanup" ) { - activatePythonEnvironment() + runSetupScript() def build_tag = getSanitizedBuildTag() executePythonScript( "ue-ci-cleanup", <%text>"--build_tag=${build_tag}" ) @@ -121,7 +121,7 @@ def postCleanupTasks() { } def preBuildGraphTasks() { - activatePythonEnvironment() + runSetupScript() fileOperations( [ @@ -142,6 +142,28 @@ def postBuildGraphTasks( String taskName ) { % endif } +def runSetupScript() { + def setupJobIdFile = "${WORKSPACE}/Saved/JenkinsSetupScriptJobId.txt" + def currentBuildTag = getSanitizedBuildTag() + + def shouldRunSetup = true + + if (fileExists(setupJobIdFile)) { + def existingTag = readFile(setupJobIdFile).trim() + if (existingTag == currentBuildTag) { + echo "Setup already ran for build tag '${currentBuildTag}'. Skipping." + shouldRunSetup = false + } + } + + if (shouldRunSetup) { + echo "Running setup script for build tag '${currentBuildTag}'..." + pwsh 'New-Item -ItemType Directory -Force -Path Saved' + writeFile file: setupJobIdFile, text: currentBuildTag + pwsh script: "${WORKSPACE}/Setup.ps1" + } +} + def getSanitizedBuildTag() { return BUILD_TAG.replace(" ", "_") } From ae20b2003062c789f6ba2ebb9fe21d8e50bb82fe Mon Sep 17 00:00:00 2001 From: Michael Delva Date: Mon, 16 Mar 2026 11:26:40 +0100 Subject: [PATCH 2/6] Updated the documentation for the unreal feature --- src/generator/features/unreal.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/generator/features/unreal.py b/src/generator/features/unreal.py index b5ce103..eff59f9 100644 --- a/src/generator/features/unreal.py +++ b/src/generator/features/unreal.py @@ -1,6 +1,7 @@ """This feature works by using Buildgraph in an Unreal Engine project. -It requires that you also use PyScripts https://github.com/TheEmidee/UEPyScripts, -which can be inside your game project or in a separate folder. +It requires that you use +* UEProjectBootStrap : https://github.com/TheEmidee/UEProjectBootstrap +* PyScripts https://github.com/TheEmidee/UEPyScripts In a nutshell, this is how this feature works: 1. Before generating any text to output in the Jenkinsfile, this feature will run the @@ -26,6 +27,9 @@ it will read them from the shared storage directory. 5. When jenkins is done, the shared storage directory is cleaned up at the end of the pipeline to avoid cluttering the disk with old results, and to make sure that there are no artifacts left from previous jobs. + +Note that the script Setup.ps1 created by UEProjectBoostrap will be called when needed before any unreal task is executed +to ensure that all the requirements (such as Python and the required moduldes) are installed on the machine. """ import subprocess From d84fc48f7f09e1b0c4cdc0f0439044010b89d3b9 Mon Sep 17 00:00:00 2001 From: Michael Delva Date: Mon, 16 Mar 2026 11:26:49 +0100 Subject: [PATCH 3/6] Pass -BuildMachine to Setup.ps1 --- src/generator/templates/unreal.mako | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/generator/templates/unreal.mako b/src/generator/templates/unreal.mako index 7d17870..9e772a9 100644 --- a/src/generator/templates/unreal.mako +++ b/src/generator/templates/unreal.mako @@ -160,7 +160,7 @@ def runSetupScript() { echo "Running setup script for build tag '${currentBuildTag}'..." pwsh 'New-Item -ItemType Directory -Force -Path Saved' writeFile file: setupJobIdFile, text: currentBuildTag - pwsh script: "${WORKSPACE}/Setup.ps1" + pwsh script: "${WORKSPACE}/Setup.ps1 -BuildMachine" } } From 9954b75e53a69a1b5264ae6f555b689f95a37dfe Mon Sep 17 00:00:00 2001 From: Michael Delva Date: Mon, 16 Mar 2026 11:31:40 +0100 Subject: [PATCH 4/6] Use the <%text> tag to escape $ in groovy --- src/generator/templates/unreal.mako | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/generator/templates/unreal.mako b/src/generator/templates/unreal.mako index 9e772a9..33fd7f0 100644 --- a/src/generator/templates/unreal.mako +++ b/src/generator/templates/unreal.mako @@ -143,7 +143,7 @@ def postBuildGraphTasks( String taskName ) { } def runSetupScript() { - def setupJobIdFile = "${WORKSPACE}/Saved/JenkinsSetupScriptJobId.txt" + <%text>def setupJobIdFile = "${WORKSPACE}/Saved/JenkinsSetupScriptJobId.txt" def currentBuildTag = getSanitizedBuildTag() def shouldRunSetup = true @@ -151,16 +151,16 @@ def runSetupScript() { if (fileExists(setupJobIdFile)) { def existingTag = readFile(setupJobIdFile).trim() if (existingTag == currentBuildTag) { - echo "Setup already ran for build tag '${currentBuildTag}'. Skipping." + <%text>echo "Setup already ran for build tag '${currentBuildTag}'. Skipping." shouldRunSetup = false } } if (shouldRunSetup) { - echo "Running setup script for build tag '${currentBuildTag}'..." + <%text>echo "Running setup script for build tag '${currentBuildTag}'..." pwsh 'New-Item -ItemType Directory -Force -Path Saved' writeFile file: setupJobIdFile, text: currentBuildTag - pwsh script: "${WORKSPACE}/Setup.ps1 -BuildMachine" + <%text>pwsh script: "${WORKSPACE}/Setup.ps1 -BuildMachine" } } From a9cd777a15d3cde8bcb7f06932ce6fc403ba8ed4 Mon Sep 17 00:00:00 2001 From: Michael Delva Date: Mon, 16 Mar 2026 11:35:06 +0100 Subject: [PATCH 5/6] Made venv_activation_script_path optional for the python feature --- src/generator/features/python.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/generator/features/python.py b/src/generator/features/python.py index 96d3113..2b80599 100644 --- a/src/generator/features/python.py +++ b/src/generator/features/python.py @@ -6,7 +6,7 @@ * executePythonScript which will execute an executable in the virtual environment's Scripts folder """ -from typing import Any, Dict, Type +from typing import Any, Dict, Optional, Type from pydantic import Field, ValidationInfo, model_validator @@ -16,11 +16,12 @@ class PythonConfig(FeatureConfig): """Configuration for the pipeline properties.""" - venv_activation_script_path: str = Field( + venv_activation_script_path: Optional[str] = Field( + default=None, description=( "The path to the virtual environment activation script." "This must point to a script that can be sourced to activate the virtual environment." - ) + ), ) venv_folder: str = Field( description="The path to the virtual environment folder after it has been created by executing venv_activation_script_path.", From b7f6b5077b9e4c1b4a51af0bdac9fc136220fac1 Mon Sep 17 00:00:00 2001 From: Michael Delva Date: Mon, 16 Mar 2026 11:41:17 +0100 Subject: [PATCH 6/6] Added towncrier changelog entry --- .changelog/33.changed.md | 1 + 1 file changed, 1 insertion(+) create mode 100644 .changelog/33.changed.md diff --git a/.changelog/33.changed.md b/.changelog/33.changed.md new file mode 100644 index 0000000..55585e5 --- /dev/null +++ b/.changelog/33.changed.md @@ -0,0 +1 @@ +Updated the unreal feature to run Setup.ps1 from UEProjectBootStrap only when the jenkins job ID is different