新增buildNumber

This commit is contained in:
WIN-IEQ8U88PPRB\Administrator 2026-02-05 14:49:14 +08:00
parent f76929f8b9
commit 1d6b7b09af
2 changed files with 141 additions and 1 deletions

View File

@ -0,0 +1,140 @@
//=================================================================
// Byway Studios Inc. Confidential Information.
// Copyright Byway Studios Inc. All rights reserved
//=================================================================
def call(Map config)
{
pipeline
{
agent
{
label config.winbakeLabel
}
options
{
skipDefaultCheckout(true) // Jenkins checkout library
}
stages
{
stage("Checkout Unity Project")
{
options
{
timeout(30)
}
steps
{
script {
// Git Windows 260
bat 'git config --global core.longpaths true'
}
checkout([
$class: 'GitSCM',
branches: [[name: '*/main']], //
userRemoteConfigs: [[
url: 'git@gitea.bywaystudios.com:pet_home/AplusB_Pet_nation.git',
credentialsId: '503eaa43-0676-40ac-81c0-d9c5cc8b4ff7'
]],
extensions: [
[$class: 'SubmoduleOption',
disableSubmodules: false,
parentCredentials: true,
recursiveSubmodules: true,
trackingSubmodules: false, //
reference: '',
timeout: 20,
threads: 1],
[$class: 'PruneStaleBranch']
]
])
}
}
stage("Build Unity Android")
{
options
{
timeout(60)
}
steps
{
BuildBundlesAndroid(config)
}
}
stage("AchiveArtifact")
{
options
{
timeout(10)
}
steps
{
archiveArtifact("Android_dev")
}
}
}
post
{
always
{
script {
//
def triggerUser = "自动触发"
def buildCause = currentBuild.getBuildCauses()
if (buildCause && buildCause.size() > 0 && buildCause[0].userName) {
triggerUser = buildCause[0].userName
}
//
def failedStage = ""
if (currentBuild.currentResult == 'FAILURE') {
def stages = currentBuild.rawBuild.getAction(org.jenkinsci.plugins.workflow.job.views.FlowGraphAction)?.getNodes()
if (stages) {
for (stage in stages) {
if (stage.getError() != null) {
failedStage = "\n- 失败阶段: ${stage.getDisplayName()}"
break
}
}
}
}
//
def changeString = ""
def changeLogSets = currentBuild.changeSets
if (changeLogSets.size() > 0) {
changeString = "\n\n提交记录:\n"
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]
changeString += "- ${entry.commitId.take(7)} ${entry.msg} - ${entry.author}\n"
}
}
} else {
changeString = "\n\n提交记录: 无变更"
}
dingtalk(
robot:'dingtalk_unity_1',
type:'MARKDOWN',
title:"${currentBuild.currentResult} - dev #${env.BUILD_NUMBER}",
text: [
"### ${currentBuild.currentResult}",
"\n构建信息:",
"- 项目: ${env.JOB_NAME}",
"- 构建号: #${env.BUILD_NUMBER}",
"- 分支: main",
"- 触发者: ${triggerUser}",
"- 耗时: ${currentBuild.durationString}${failedStage}",
"\n链接:",
"- [下载链接](${env.BUILD_URL})",
changeString
]
)
}
}
}
}
}

View File

@ -32,6 +32,6 @@ def call(clearPackageCache,methodName)
bat label: "Executing Unity method: ${methodName}", script: """
set UNITY_PATH=C:\\Program Files\\Unity\\Hub\\Editor\\${gUnityVersion_Windows}\\Editor\\Unity.exe
for /f %%i in ('git rev-parse --short HEAD') do set GIT_HASH=%%i
"%UNITY_PATH%" -quit -batchmode -nographics -projectPath "${WORKSPACE}" -executeMethod "${methodName}" -buildTarget Android -gitHash %GIT_HASH% -stackTraceLogType None -logFile -
"%UNITY_PATH%" -quit -batchmode -nographics -projectPath "${WORKSPACE}" -executeMethod "${methodName}" -buildTarget Android -gitHash %GIT_HASH% -buildNumber %BUILD_NUMBER% -stackTraceLogType None -logFile -
"""
}