将加密值从 xml 文件传递​​给 ms build 命令

将加密值从 xml 文件传递​​给 ms build 命令

我有一个包含密码的 xml 文件。我必须将这些密码从 xml 文件传递​​到 MSBUILD 命令中的密码属性。有人可以指导我吗

XML文件:

<?xml versio------>
<configuration>
<password>newpassword</password>
</configuration>

我的 msbuild 命令是:

Msbuild "projectpath" /p:deployonbuild=true /p:username='user's /p:password=' '

答案1

有一个xml模块https://docs.ansible.com/ansible/latest/collections/community/general/xml_module.html这里有一个从 XML 文件中检索 xml 值的示例

# Consider the following XML file:
#
# <business type="bar">
#   <name>Tasty Beverage Co.</name>
#     <beers>
#       <beer>Rochefort 10</beer>
#       <beer>St. Bernardus Abbot 12</beer>
#       <beer>Schlitz</beer>
#    </beers>
#   <rating subjective="true">10</rating>
#   <website>
#     <mobilefriendly/>
#     <address>http://tastybeverageco.com</address>
#   </website>
# </business>

# Retrieve and display the number of nodes
- name: Get count of 'beers' nodes
  community.general.xml:
    path: /foo/bar.xml
    xpath: /business/beers/beer
    count: yes
  register: hits

- ansible.builtin.debug:
    var: hits.count

# ...

# How to read an attribute value and access it in Ansible
- name: Read an element's attribute values
  xml:
    path: /foo/bar.xml
    xpath: /business/website/validxhtml
    content: attribute
  register: xmlresp

- name: Show an attribute value
  debug:
    var: xmlresp.matches[0].validxhtml.validatedon

您可以根据自己的需要采用它。在 Ansible 2.9 中,请使用xml代替community.general.xml,并注意安装必要的库(lxml)

相关内容