Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env groovy
- package hudson.scm
- import groovy.io.FileType
- def RunEditorStages = false
- def RunCompileStages = false
- def RunCookStages = false
- def MergeToStable = false
- def RunPackageRelease = false
- def RunDeploy = false
- def UploadToS3 = false
- def BuildPlatforms = [
- [
- Name: "Android Client",
- BuildGraphClientTarget: "Compile Client Android",
- BuildGraphCookTarget: "Cook Android",
- Package: ""
- ],
- [
- Name: "Windows Client",
- BuildGraphClientTarget: "Compile Client Win64",
- BuildGraphCookTarget: "Cook WindowsNoEditor",
- Package: ""
- ]
- ]
- def WindowsServerPlatform = [
- Name: "Windows Server",
- BuildGraphClientTarget: "Compile Server Win64",
- BuildGraphCookTarget: "Cook WindowsServer",
- Package: ""
- ]
- def LinuxServerPlatform = [
- Name: "Linux Server",
- BuildGraphClientTarget: "Compile Server Linux",
- BuildGraphCookTarget: "Cook LinuxServer",
- Package: ""
- ]
- def Workspace = "E:\\Jenkins\\workspace\\MyProject-Programming (CI)"
- pipeline
- {
- agent
- {
- node
- {
- label 'windows'
- }
- }
- parameters
- {
- booleanParam(name: 'ForceEditor', defaultValue: false, description: 'Force this job to compile editor whether there were code changes or not')
- booleanParam(name: 'ForceCompile', defaultValue: false, description: 'Force this job to compile whether there were code changes or not')
- booleanParam(name: 'ForceCook', defaultValue: false, description: 'Force this job to cook whether there were asset changes or not')
- booleanParam(name: 'ForceDeploy', defaultValue: false, description: 'Force this job to remove old servers and deploy the new server')
- booleanParam(name: 'ForcePackage', defaultValue: false, description: 'Force this job to package and release the clients for all platforms')
- booleanParam(name: 'ForceS3Upload', defaultValue: false, description: 'Force this job to upload the build files to S3')
- string(name: 'GameConfiguration', defaultValue: "Development", description: 'Development or Shipping')
- booleanParam(name: 'LinuxServer', defaultValue: false, description: 'True if the platform of the server build should be Linux, otherwise false')
- }
- environment
- {
- ProjectName = "DS_Template"
- ProjectDepotPath = "//MyProject/main"
- ProjectGamePath = "/${ProjectName}"
- ProjectEditorBinariesDepotPath = "//MyProject/binaries"
- ProjectWorkSpace = "jenkins-${JOB_NAME}"
- UATPath = "Engine\\Build\\BatchFiles\\RunUAT.bat"
- PostBadgeStatusPath = "Engine\\Build\\BatchFiles\\PostBadgeStatus.bat"
- UGSRestUrl = "http://bumblebee:8081"
- BuildEditorBuildGraphScript = "Engine/Build/Graph/Examples/BuildEditorAndTools.xml"
- BuildGameBuildGraphScript = "${ProjectName}/Build/Graph/PackageGame.xml"
- CookGameBuildGraphScript = "${ProjectName}/Build/Graph/PackageGame.xml"
- AppBatchFilesPath = "${ProjectName}\\Build\\BatchFiles"
- LocalDeployDirectory = "${ProjectName}\\Deploy"
- LocalArchiveDirectory = "${ProjectName}\\Deploy\\Archives"
- uebp_PORT = "${env.P4_PORT}"
- uebp_CLIENT = "${env.P4_CLIENT}"
- uebp_USER = "${env.P4_USER}"
- }
- stages
- {
- stage ('Check Change List')
- {
- steps
- {
- script
- {
- String[] SourceFileTypes = [".cpp", ".h", ".hpp", ".cs", ".jenkins-ci", ".bat", ".uproject", ".uplugin"]
- String[] ContentFileTypes = [".uasset", ".umap", ".ini", ".jenkins-ci"]
- if (params.ForceEditor)
- {
- RunEditorStages = true
- }
- else
- {
- RunEditorStages = searchChangeListForFileTypes(SourceFileTypes)
- }
- if (params.ForceCompile)
- {
- RunCompileStages = true
- }
- else
- {
- RunCompileStages = searchChangeListForFileTypes(SourceFileTypes)
- }
- if (params.ForceCook)
- {
- RunCookStages = true
- }
- else
- {
- RunCookStages = searchChangeListForFileTypes(ContentFileTypes)
- }
- if (params.ForceDeploy)
- {
- RunDeploy = true
- }
- else
- {
- RunDeploy = searchChangeListForFileTypes(ContentFileTypes) || searchChangeListForFileTypes(SourceFileTypes)
- }
- if (params.ForcePackage)
- {
- RunPackageRelease = true
- }
- else
- {
- RunPackageRelease = searchChangeListForFileTypes(ContentFileTypes) || searchChangeListForFileTypes(SourceFileTypes)
- }
- if (params.ForceS3Upload)
- {
- UploadToS3 = true
- }
- else
- {
- // TODO: think about this more
- UploadToS3 = ForcePackage || ForceDeploy
- }
- if (!RunEditorStages)
- {
- bat """%PostBadgeStatusPath% -Name=Editor -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Success -Url=%BUILD_URL%"""
- }
- }
- }
- }
- stage('Compile Editor')
- {
- when
- {
- expression { RunEditorStages == true }
- }
- steps
- {
- bat """%PostBadgeStatusPath% -Name=Editor -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Starting -Url=%BUILD_URL%"""
- bat """%UATPath% BuildGraph -Script=%BuildEditorBuildGraphScript% -Target="Submit To Perforce for UGS" -set:EditorTarget=%ProjectName%Editor -set:ArchiveStream=%ProjectEditorBinariesDepotPath% -p4 -submit -verbose -BuildMachine"""
- }
- post
- {
- success
- {
- bat """%PostBadgeStatusPath% -Name=Editor -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Success -Url=%BUILD_URL%"""
- }
- failure
- {
- bat """%PostBadgeStatusPath% -Name=Editor -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Failure -Url=%BUILD_URL%"""
- }
- }
- }
- stage('Compile Game')
- {
- when
- {
- expression { RunCompileStages == true }
- }
- steps
- {
- bat """%PostBadgeStatusPath% -Name=Game -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Starting -Url=%BUILD_URL%"""
- script
- {
- if (params.LinuxServer)
- {
- BuildPlatforms << LinuxServerPlatform
- }
- else
- {
- BuildPlatforms << WindowsServerPlatform
- }
- for (Platform in BuildPlatforms)
- {
- stage(Platform.Name)
- {
- bat """%UATPath% BuildGraph -Script=%BuildGameBuildGraphScript% -Target="${Platform.BuildGraphClientTarget}" -set:GameConfiguration=${params.GameConfiguration} -BuildMachine"""
- }
- }
- }
- }
- post
- {
- success
- {
- bat """%PostBadgeStatusPath% -Name=Game -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Success -Url=%BUILD_URL%"""
- }
- failure
- {
- bat """%PostBadgeStatusPath% -Name=Game -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Failure -Url=%BUILD_URL%"""
- }
- }
- }
- stage('Cook Game')
- {
- when
- {
- expression { RunCookStages == true }
- }
- steps
- {
- bat """%PostBadgeStatusPath% -Name=Cook -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Starting -Url=%BUILD_URL%"""
- script
- {
- for (Platform in BuildPlatforms)
- {
- stage(Platform.Name)
- {
- bat """%UATPath% BuildGraph -Script=%CookGameBuildGraphScript% -Target="${Platform.BuildGraphCookTarget}" -BuildMachine"""
- def logLines = currentBuild.rawBuild.getLog(200)
- for (int i = 0; i < logLines.size(); i++)
- {
- def logLine = logLines[i]
- if (logLine.contains("Array Inner Type mismatch") || logLine.contains("Can't find file"))
- {
- currentBuild.result = 'UNSTABLE'
- break;
- }
- }
- }
- }
- }
- }
- post
- {
- success
- {
- bat """%PostBadgeStatusPath% -Name=Cook -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Success -Url=%BUILD_URL%"""
- }
- failure
- {
- bat """%PostBadgeStatusPath% -Name=Cook -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Failure -Url=%BUILD_URL%"""
- }
- unstable
- {
- bat """%PostBadgeStatusPath% -Name=Cook -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Warning -Url=%BUILD_URL%"""
- }
- }
- }
- stage('Deploy Server')
- {
- when
- {
- expression { RunDeploy == true }
- }
- steps
- {
- bat """%PostBadgeStatusPath% -Name=Deploy -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Starting -Url=%BUILD_URL%"""
- script
- {
- bat """%UATPath% BuildGraph -Script=%BuildGameBuildGraphScript% -Target="CleanUp PlayFabServers" -BuildMachine"""
- if (params.LinuxServer)
- {
- // bat """%UATPath% BuildGraph -Script=%BuildGameBuildGraphScript% -Target="Stage LinuxServer" -set:GameConfiguration=${params.GameConfiguration} -set:ArchiveDirectory=%LocalDeployDirectory% -BuildMachine"""
- bat """%UATPath% BuildGraph -Script=%BuildGameBuildGraphScript% -Target="Deploy LinuxServer" -set:GameConfiguration=${params.GameConfiguration} -set:ArchiveDirectory=%LocalDeployDirectory% -BuildMachine"""
- }
- else
- {
- // bat """%UATPath% BuildGraph -Script=%BuildGameBuildGraphScript% -Target="Stage WindowsServer" -set:GameConfiguration=${params.GameConfiguration} -set:ArchiveDirectory=%LocalDeployDirectory% -BuildMachine"""
- bat """%UATPath% BuildGraph -Script=%BuildGameBuildGraphScript% -Target="Deploy WindowsServer" -set:GameConfiguration=${params.GameConfiguration} -set:ArchiveDirectory=%LocalDeployDirectory% -BuildMachine"""
- }
- }
- }
- post
- {
- success
- {
- bat """%PostBadgeStatusPath% -Name=Deploy -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Success -Url=%BUILD_URL%"""
- }
- failure
- {
- bat """%PostBadgeStatusPath% -Name=Deploy -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Failure -Url=%BUILD_URL%"""
- }
- unstable
- {
- bat """%PostBadgeStatusPath% -Name=Deploy -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Warning -Url=%BUILD_URL%"""
- }
- }
- }
- stage('Package Game')
- {
- when
- {
- expression { RunPackageRelease == true }
- }
- steps
- {
- script
- {
- bat """%PostBadgeStatusPath% -Name=Release -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Starting -Url=%BUILD_URL%"""
- bat """%UATPath% BuildGraph -Script=%BuildGameBuildGraphScript% -Target="Stage Android" -set:GameConfiguration=${params.GameConfiguration} -set:ArchiveDirectory=%LocalDeployDirectory% -BuildMachine"""
- bat """%UATPath% BuildGraph -Script=%BuildGameBuildGraphScript% -Target="Stage WindowsNoEditor" -set:GameConfiguration=${params.GameConfiguration} -set:ArchiveDirectory=%LocalDeployDirectory% -BuildMachine"""
- bat """%UATPath% BuildGraph -Script=%BuildGameBuildGraphScript% -Target="Generate CL and Archive Builds" -set:GameConfiguration=${params.GameConfiguration} -set:ChangeList=%P4_CHANGELIST% -set:P4Root=%ProjectDepotPath% -BuildMachine"""
- }
- }
- post
- {
- success
- {
- bat """%PostBadgeStatusPath% -Name=Release -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Success -Url=%BUILD_URL%"""
- }
- failure
- {
- bat """%PostBadgeStatusPath% -Name=Release -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Failure -Url=%BUILD_URL%"""
- }
- unstable
- {
- bat """%PostBadgeStatusPath% -Name=Release -Change=%P4_CHANGELIST% -Project=%ProjectDepotPath%%ProjectGamePath% -RestUrl=%UGSRestUrl% -Status=Warning -Url=%BUILD_URL%"""
- }
- }
- }
- }
- }
- @NonCPS
- def searchChangeListForFileTypes(String[] fileTypes)
- {
- //According to docs should be able to use a changeset expression in the when clause but that wouldn't work.
- def changeLogSets = currentBuild.rawBuild.getChangeSets()
- for (int i = 0; i < changeLogSets.size(); i++)
- {
- def entries = changeLogSets[i].items
- for (int j = 0; j < entries.length; j++)
- {
- def entry = entries[j]
- def files = new ArrayList(entry.affectedFiles)
- for (int k = 0; k < files.size(); k++)
- {
- def file = files[k].path
- echo "${file}"
- for (int l = 0; l < fileTypes.length; l++)
- {
- def fileType = fileTypes[l]
- echo "${fileType}"
- if (file.contains(fileType))
- {
- return true
- }
- }
- }
- }
- }
- return false
- }
- @NonCPS
- def searchChangeListForCommitComment(String tag)
- {
- //According to docs should be able to use a changeset expression in the when clause but that wouldn't work.
- def changeLogSets = currentBuild.rawBuild.getChangeSets()
- for (int i = 0; i < changeLogSets.size(); i++)
- {
- def entries = changeLogSets[i].items
- for (int j = 0; j < entries.length; j++)
- {
- def entry = entries[j]
- def message = entry.msg;
- if (message.contains(tag))
- {
- return true;
- }
- }
- }
- return false
- }
- @NonCPS
- def findReleaseVersion()
- {
- //According to docs should be able to use a changeset expression in the when clause but that wouldn't work.
- def changeLogSets = currentBuild.rawBuild.getChangeSets()
- for (int i = 0; i < changeLogSets.size(); i++)
- {
- def entries = changeLogSets[i].items
- for (int j = 0; j < entries.length; j++)
- {
- def entry = entries[j]
- def message = entry.msg;
- if (message.contains("#release"))
- {
- int releaseIndex = message.indexOf("#release")
- return message.substring(releaseIndex + 1, releaseIndex + 6)
- }
- }
- }
- return ""
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement