Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add the third version of the build unity wdk pipeline, #251

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
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 .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ target
build/
out/
.idea/
*bin/

# Ignore Gradle GUI config
gradle-app.setting
Expand Down
213 changes: 213 additions & 0 deletions vars/buildUnityWdkV3.groovy
Original file line number Diff line number Diff line change
@@ -0,0 +1,213 @@
#!/usr/bin/env groovy
import net.wooga.jenkins.pipeline.check.steps.Step
import net.wooga.jenkins.pipeline.config.PipelineConventions
import net.wooga.jenkins.pipeline.config.Platform
import net.wooga.jenkins.pipeline.config.WDKConfig

////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// //
// Step buildUnityWdkV3 //
// //
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

def call(Map configMap = [unityVersions: []]) {

def defaultReleaseType = "snapshot"
def defaultReleaseScope = ""

configMap.logLevel = configMap.get("logLevel", params.LOG_LEVEL ?: env.LOG_LEVEL as String)
configMap.showStackTrace = configMap.get("showStackTrace", params.STACK_TRACE as Boolean)
configMap.refreshDependencies = configMap.get("refreshDependencies", params.REFRESH_DEPENDENCIES as Boolean)
configMap.clearWs = configMap.get("clearWs", params.CLEAR_WS as boolean)
configMap.testWrapper = { Step testOperation, Platform plat ->
if(env."UNITY_PACKAGE_MANAGER" == "upm") {
withCredentials([file(credentialsId: 'atlas-upm-credentials', variable: "UPM_USER_CONFIG_FILE")]) {
testOperation(plat)
}
} else {
testOperation(plat)
}

}

def config = WDKConfig.fromConfigMap(configMap, this)
def packageManagerEnvVar = "UNITY_PACKAGE_MANAGER"

// We can only configure static pipelines atm.
// To test multiple unity versions we use a script block with a parallel stages inside.
pipeline {
agent none

options {
buildDiscarder(logRotator(artifactNumToKeepStr: '40'))
}

environment {
UVM_AUTO_SWITCH_UNITY_EDITOR = "YES"
UVM_AUTO_INSTALL_UNITY_EDITOR = "YES"
LOG_LEVEL = "${config.gradleArgs.logLevel}"
ATLAS_READ = credentials('artifactory_read') //needed for gradle sto read private packages
}

parameters {
choice(name: 'RELEASE_STAGE', choices: ["snapshot", "preflight", "rc", "final"], description: 'Choose the distribution type')
choice(name: 'RELEASE_SCOPE', choices: ["", "patch", "minor", "major"], description: 'Choose the scope (semver2)')
choice(name: 'LOG_LEVEL', choices: ["info", "quiet", "warn", "debug"], description: 'Choose the log level')
choice(name: 'UPM_RESOLUTION_STRATEGY', choices: ["", "lowest", "highestPatch", "highestMinor", "highest"], description: 'Override the resolution strategy for indirect dependencies')
booleanParam(name: 'STACK_TRACE', defaultValue: false, description: 'Whether to log truncated stacktraces')
booleanParam(name: 'REFRESH_DEPENDENCIES', defaultValue: false, description: 'Whether to refresh dependencies')
booleanParam(name: 'CLEAR_WS', defaultValue: false, description: 'Whether to clear workspaces after build')
}

stages {

stage("Setup") {
failFast true
agent {
label "atlas && macos"
}
environment {
UPM_USER_CONFIG_FILE = credentials('atlas-upm-credentials')
UNITY_PACKAGE_MANAGER = 'upm'
}
steps {
script {
env.RELEASE_STAGE = params.RELEASE_STAGE?: defaultReleaseType
env.RELEASE_SCOPE = params.RELEASE_SCOPE?: defaultReleaseScope
def setup = config.pipelineTools.setups
setup.wdk(env.RELEASE_STAGE as String, env.RELEASE_SCOPE as String)
}
}
post {
success {
archiveArtifacts artifacts: '**/Packages/packages-lock.json'
stash(name: 'upm_setup_w', useDefaultExcludes: true, includes: "**/Packages/packages-lock.json, " +
"**/PackageCache/**, " +
"**/build/**")
}

always {
archiveArtifacts artifacts: '**/build/logs/*.log', allowEmptyArchive: true
}
cleanup {
script {
if(config.mainPlatform.clearWs) {
cleanWs()
}
}
}
}
}

stage("Build") {
failFast true
parallel {
stage('assemble package') {
agent {
label "atlas && macos"
}
environment {
UNITY_PACKAGE_MANAGER = 'upm'
UPM_USER_CONFIG_FILE = credentials('atlas-upm-credentials')
JAVA_HOME = "${JAVA_11_HOME}"
}
steps {
unstash 'upm_setup_w'
script {
def assembler = config.pipelineTools.assemblers
assembler.unityWDK("build", params.RELEASE_STAGE as String, params.RELEASE_SCOPE as String)
}
}

post {
always {
stash(name: 'wdk_output', includes: ".gradle/**, **/build/outputs/**/*")
archiveArtifacts artifacts: '**/build/distributions/*.tgz', allowEmptyArchive: true
archiveArtifacts artifacts: 'build/outputs/*.unitypackage', allowEmptyArchive: true
archiveArtifacts artifacts: '**/build/logs/*.log', allowEmptyArchive: true
}
cleanup {
script {
if(config.mainPlatform.clearWs) {
cleanWs()
}
}
}
}
}

stage("Check") {
failFast true
when {
beforeAgent true
expression {
return params.RELEASE_STAGE == "snapshot"
}
}
steps {
script {
withEnv(["UNITY_PACKAGE_MANAGER=upm"]) {
parallel checkSteps(config, "upm check unity", "upm_setup_w")
}
failFast : true
}
}
}
}
}

stage('publish') {
agent {
label "atlas && macos"
}

environment {
GRGIT = credentials('github_access')
UPM_USER_CONFIG_FILE = credentials('atlas-upm-credentials')
GRGIT_USER = "${GRGIT_USR}"
GRGIT_PASS = "${GRGIT_PSW}"
GITHUB_LOGIN = "${GRGIT_USR}"
GITHUB_PASSWORD = "${GRGIT_PSW}"
}

steps {
unstash 'upm_setup_w'
unstash 'wdk_output'
script {
def publisher = config.pipelineTools.createPublishers(params.RELEASE_STAGE, params.RELEASE_SCOPE)
publisher.unityArtifactoryUpm('artifactory_publish')
}
}

post {
always {
archiveArtifacts artifacts: '**/build/logs/*.log', allowEmptyArchive: true
}
cleanup {
script {
if(config.mainPlatform.clearWs) {
cleanWs()
}
}
}
}
}
}
post {
always {
sendSlackNotification currentBuild.result, true
}
}
}
}

def checkSteps(WDKConfig config, String parallelChecksPrefix, String setupStashId) {
def conventions = new PipelineConventions(config.conventions)
conventions.wdkParallelPrefix = parallelChecksPrefix
conventions.wdkSetupStashId = setupStashId
def checks = config.pipelineTools.checks.forWDKPipelines()
def stepsForParallel = checks.wdkCoverage(config.unityVersions,
params.RELEASE_STAGE as String, params.RELEASE_SCOPE as String,
config.checkArgs, conventions)
return stepsForParallel
}
26 changes: 26 additions & 0 deletions vars/buildUnityWdkV3.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
Custom step to build, test and deploy Wooga's Unity projects with Gradle 7 and Java 11.

Arguments:

- unityVersions: []
- $VERSION: ""
- $OPTIONAL: [true, false]
- $API_COMPAT_LEVEL: [net4_6, net2_0_subset]
- refreshDependencies: [true, false]
- logLevel: [quiet, warning, info, debug]
- testLabels: []
- labels: []

Usage:

"def args =
[
refreshDependencies : true,
unityVersions :
[
'$VERSION1',
'$VERSION2',
[version : '$VERSION3', optional : $BOOLEAN, apiCompatibilityLevel: '$API_COMPAT_LEVEL'],
]
]
buildWDKAutoSwitch args"