gpt4 book ai didi

xml - 无发布管道中的 Azure XML 转换

转载 作者:行者123 更新时间:2023-12-03 02:32:30 24 4
gpt4 key购买 nike

在普通的Azure管道(无版本)中,根据输入参数,我想编辑管道中使用的XML文件。例如,如果需要,我想更改日志级别。接下来,该文件将通过 az storage file upload

加载
- task: myTask@1
displayName: 'Upload Config File'
inputs:
scriptLocation: 'inlineScript'
inlineScript: |
myConfiguration="${{ parameters.name }}-configuration.xml"
# here want to modify the xml above
az storage file upload --share-name $(config-file-share) \
--source "$(input-files-path)/${myConfiguration}"

读完后 Azure File transforms and variable substitution reference我有点迷失了...我可以在没有发布管道的情况下使用它吗?但是如果可以的话,我不知道如何应用它...很难找到一个好的解决方案例子。我认为更简单的方法就是使用 awk。

您能否分享一下您的意见并举个例子(如果有的话)?

最佳答案

Can I use is it mechanism in no release pipeline?

当然。您可以在普通的 Azure 管道中完成此操作。

但是替换xml文件的值时,需要用到变量,所以需要将参数的值转换为变量的值。

您可以使用 Replace token extension 中的替换 token 任务 .

这是一个例子:

XML 文件:

enter image description here

Yaml 示例:

parameters:
- name: test
type: string
default: aa
variables:
- name: a
value: ${{ parameters.test }}

pool:
vmImage: 'ubuntu-latest'

steps:
- script: echo $(a)
displayName: 'Run a one-line script'

- task: replacetokens@3
inputs:
rootDirectory: '$(build.sourcesdirectory)'
targetFiles: '**/*.xml'
encoding: 'auto'
writeBOM: true
actionOnMissing: 'warn'
keepToken: false
tokenPrefix: '#{'
tokenSuffix: '}#'
useLegacyPattern: false
enableTelemetry: true

参数的输入值:changevalue

结果:

enter image description here

顺便说一句,您也可以使用 the file transform task 。这个任务是通过文件来转换变量。

关于xml - 无发布管道中的 Azure XML 转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64524225/

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