Jenkins上传apk 包 token当作python参数上传

This commit is contained in:
zhang hongbo 2026-05-09 11:56:48 +08:00
parent b24135b02c
commit 9026dbe981
3 changed files with 29 additions and 3 deletions

View File

@ -10,5 +10,5 @@ Pipeline_dev(
winbakeLabel: "unity_2022_3_dev", // optional node labels. Valid entries: macbakeLabel, linuxbakeLabel, winbakeLabel, syncLabel
execUnityMethod:"MyBuildTool.StartBuildAndroid_dev",
uploadEnabled: true,
uploadTokenCredentialsId: "apk-upload-token",
uploadToken: "apk-upload-token",
)

View File

@ -0,0 +1,14 @@
//=================================================================
// Byway Studios Inc. Confidential Information.
// Copyright Byway Studios Inc. All rights reserved
//=================================================================
// The configuration is done in Jenkins -> Manage Jenkins -> Configure System -> Global Pipeline Libraries
@Library("my-shared-lib") _
Pipeline_dev(
winbakeLabel: "unity_2022_3_dev", // optional node labels. Valid entries: macbakeLabel, linuxbakeLabel, winbakeLabel, syncLabel
execUnityMethod:"MyBuildTool.StartBuildAndroid_dev",
uploadEnabled: true,
uploadToken: "apk-upload-token",
)

View File

@ -8,7 +8,8 @@ def call(Map config)
def publishSubFolder = config.publishSubFolder
def uploadEnv = config.uploadEnv
def uploadUrl = config.uploadUrl ?: 'https://gadmin.bywaystudios.com/api/open/apk/upload/'
def uploadTokenCredentialsId = config.uploadTokenCredentialsId ?: 'apk-upload-token'
def uploadToken = (config.uploadToken ?: '').trim()
def uploadTokenCredentialsId = (config.uploadTokenCredentialsId ?: 'apk-upload-token').trim()
def packageType = config.packageType ?: 'with_sdk'
if (!publishSubFolder) {
@ -56,11 +57,22 @@ def call(Map config)
pythonArgs << " --version \"${version}\""
}
withCredentials([string(credentialsId: uploadTokenCredentialsId, variable: 'APK_UPLOAD_TOKEN')]) {
if (uploadToken) {
pythonArgs << " --token \"${uploadToken}\""
bat(
label: 'Upload APK to server',
script: "@echo off\r\n" + pythonArgs.join(" ^\r\n")
)
} else if (uploadTokenCredentialsId) {
withCredentials([string(credentialsId: uploadTokenCredentialsId, variable: 'APK_UPLOAD_TOKEN')]) {
pythonArgs << " --token \"%APK_UPLOAD_TOKEN%\""
bat(
label: 'Upload APK to server',
script: "@echo off\r\n" + pythonArgs.join(" ^\r\n")
)
}
} else {
error('Either uploadToken or uploadTokenCredentialsId must be provided for APK upload.')
}
return [