Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .changelog/33.changed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Updated the unreal feature to run Setup.ps1 from UEProjectBootStrap only when the jenkins job ID is different
7 changes: 4 additions & 3 deletions src/generator/features/python.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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.",
Expand Down
8 changes: 6 additions & 2 deletions src/generator/features/unreal.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
Expand Down
26 changes: 24 additions & 2 deletions src/generator/templates/unreal.mako
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ def cleanup() {
projectCheckout()

stage ( "Cleanup" ) {
activatePythonEnvironment()
runSetupScript()

def build_tag = getSanitizedBuildTag()
executePythonScript( "ue-ci-cleanup", <%text>"--build_tag=${build_tag}"</%text> )
Expand All @@ -121,7 +121,7 @@ def postCleanupTasks() {
}

def preBuildGraphTasks() {
activatePythonEnvironment()
runSetupScript()

fileOperations(
[
Expand All @@ -142,6 +142,28 @@ def postBuildGraphTasks( String taskName ) {
% endif
}

def runSetupScript() {
<%text>def setupJobIdFile = "${WORKSPACE}/Saved/JenkinsSetupScriptJobId.txt"</%text>
def currentBuildTag = getSanitizedBuildTag()

def shouldRunSetup = true

if (fileExists(setupJobIdFile)) {
def existingTag = readFile(setupJobIdFile).trim()
if (existingTag == currentBuildTag) {
<%text>echo "Setup already ran for build tag '${currentBuildTag}'. Skipping."</%text>
shouldRunSetup = false
}
}

if (shouldRunSetup) {
<%text>echo "Running setup script for build tag '${currentBuildTag}'..."</%text>
pwsh 'New-Item -ItemType Directory -Force -Path Saved'
writeFile file: setupJobIdFile, text: currentBuildTag
<%text>pwsh script: "${WORKSPACE}/Setup.ps1 -BuildMachine"</%text>
}
}

def getSanitizedBuildTag() {
return BUILD_TAG.replace(" ", "_")
}
Expand Down
Loading