gpt4 book ai didi

azure-devops - Azure 开发运营 : Populating secure file references with job matrix variables

转载 作者:行者123 更新时间:2023-12-04 08:05:44 27 4
gpt4 key购买 nike

对于上下文,我正在尝试使用 Azure 构建管道来构建多种风格的 Android 应用程序。每种风格都有自己独立的签名 keystore ,所有这些 keystore 都存储在我库中的“安全文件”中。

但是,当我在“android 签名”任务期间尝试取消引用 $(Keystore) 变量时,它似乎没有意识到这是一个存在的变量,而是尝试找到一个名为“$( keystore )'

我是不是做错了什么?这似乎应该有效。

经过清理的示例如下所示:

# Android
# Build your Android project with Gradle.
# Add steps that test, sign, and distribute the APK, save build artifacts, and more:
# https://learn.microsoft.com/azure/devops/pipelines/languages/android

trigger:
- feat/ci-setup

pool:
vmImage: 'macos-latest'

variables:
${{ if startsWith(variables['build.sourceBranch'], 'refs/heads/feat/') }}:
Branch_Type: 'feature'
${{ if startsWith(variables['build.sourceBranch'], 'refs/heads/hotfix/') }}:
Branch_Type: 'hotfix'
${{ if startsWith(variables['build.sourceBranch'], 'refs/heads/release/') }}:
Branch_Type: 'release'
${{ if eq(variables['Branch_Type'], 'release') }}:
Configuration: 'release'
ConfigurationCC: 'Release'
${{ if ne(variables['Branch_Type'], 'release') }}:
Configuration: 'debug'
ConfigurationCC: 'Debug'

jobs:
- job: Build
variables:
- group: android_keystores
strategy:
maxParallel: 2
matrix:
Flavor_1:
AppFlavor: '1'
AppFlavorCC: '1'
Keystore: 'flavor1.keystore'
KeyAlias: 'flavor1'
KeystorePass: '$(flavor1_storepass)'
KeyPass: '$(flavor1_keypass)'
Flavor_2:
AppFlavor: '2'
AppFlavorCC: '2'
Keystore: 'flavor2.keystore'
KeyAlias: 'flavor2'
KeystorePass: '$(flavor2_storepass)'
KeyPass: '$(flavor2_keypass)'

steps:
- task: Gradle@2
inputs:
workingDirectory: ''
gradleWrapperFile: 'gradlew'
gradleOptions: '-Xmx3072m'
publishJUnitResults: false
tasks: 'assemble$(AppFlavorCC)$(ConfigurationCC)'

- task: AndroidSigning@3
displayName: Signing .apk
inputs:
apkFiles: 'app/build/outputs/apk/$(AppFlavor)/$(Configuration)/*.apk'
apksign: true
apksignerKeystoreFile: '$(Keystore)'
apksignerKeystorePassword: '$(KeystorePass)'
apksignerKeystoreAlias: '$(KeyAlias)'
apksignerKeyPassword: '$(KeyPass)'
zipalign: true

- task: Bash@3
displayName: Move APK to Artifact Folder
continueOnError: true
inputs:
targetType: 'inline'
script: |
mv \
app/build/outputs/apk/$(AppFlavor)/$(Configuration)/*.apk \
$(Build.ArtifactStagingDirectory)/$(ArtifactName)/

- task: PublishBuildArtifacts@1
displayName: Publish Build Artifacts
inputs:
PathtoPublish: '$(Build.ArtifactStagingDirectory)'
ArtifactName: 'Blueprint-Build'
publishLocation: 'Container'

但是当管道运行时,我被告知:

There was a resource authorization issue: "The pipeline is not valid. Job Build: Step AndroidSigning input keystoreFile references secure file $(Keystore) which could not be found. The secure file does not exist or has not been authorized for use. For authorization details, refer to https://aka.ms/yamlauthz."

最佳答案

Azure DevOps: Populating secure file references with job matrix variables

这是任务本身的限制。

当我们使用经典模式进行测试时,我们发现无法手动输入Keystore file选项的值,我们只能通过下拉菜单选择某个文件:

enter image description here

这就是为什么它似乎没有意识到这是一个存在的变量,而是试图找到一个名为“$(Keystore)”的文件的原因。

要解决此问题,您可以将任务版本从3更改为支持手动输入的1:

enter image description here

作为另一种解决方案,您还可以使用命令行对 *.apk 进行签名:

Android apk signing: sign an unsigned apk using command line

关于azure-devops - Azure 开发运营 : Populating secure file references with job matrix variables,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66231033/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com