使用 Octopus Deploy 3 替换 .config 文件中的变量
Variable Substitution in .config file with Octopus Deploy 3
我正在使用 Octopus Deploy v3 进行部署。
在我的项目中,我定义了一个名为 data.folder
的变量
我正在尝试使用此变量在使用包部署的转换文件中设置值
我有以下 .config 文件
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" >
<sitecore>
<sc.variable name="dataFolder">
<patch:attribute name="value">/Data</patch:attribute>
</sc.variable>
</sitecore>
</configuration>
和以下 .ci.config 文件
<?xml version="1.0"?>
<configuration
xmlns:patch="http://www.sitecore.net/xmlconfig/"
xmlns:set="http://www.sitecore.net/xmlconfig/set/"
xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<sitecore>
<sc.variable name="dataFolder" xdt:Transform="Replace" xdt:Location="Match(name)" set:value="#{data.folder}" />
</sitecore>
</configuration>
这两个文件都位于文件夹 App_Config\Include
中
如您所见,我已将转换文件中的变量设置为包含变量“{data.folder}”
在 Octopus 中,我创建了一个包部署步骤,并设置了以下功能:
- 自定义安装目录
- 配置变量
- 配置转换
- 替换文件中的变量
在文件中的替换变量中,我包含了目标文件
App_Config\Include\Z_Project.#{Octopus.Environment.Id}.config
我相信我已经正确地遵循了 http://docs.octopusdeploy.com/display/OD/Substitute+Variables+in+Files,但是当部署运行时。 .ci.config 文件中的变量未被设置。
我确定我犯了一个非常基本的错误,但我不知道我做错了什么
我需要什么来获取转换文件以使用来自 Octopus 的变量
听起来您的过程在步骤、变量等方面是正确的,但我认为 .ci.config 文件中的转换在预览转换后不正确。
结果是这样
<sitecore>
<sc.variable name="dataFolder" set:value="#{data.folder}"/>
</sitecore>
尝试使用
<sitecore>
<sc.variable name="dataFolder" xdt:Transform="Replace" xdt:Location="Match(name)">
<patch:attribute name="value">#{data.folder}</patch:attribute>
</sc.variable>
</sitecore>
运行 这通过 Slow Cheetah (Visual Studio Gallery) 正确执行转换,并且如果在 Octopus Deploy 中正确设置了其他所有内容,这应该在转换发生之前获得注入的值。
希望对您有所帮助
我正在使用 Octopus Deploy v3 进行部署。
在我的项目中,我定义了一个名为 data.folder
的变量我正在尝试使用此变量在使用包部署的转换文件中设置值
我有以下 .config 文件
<?xml version="1.0"?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:set="http://www.sitecore.net/xmlconfig/set/" >
<sitecore>
<sc.variable name="dataFolder">
<patch:attribute name="value">/Data</patch:attribute>
</sc.variable>
</sitecore>
</configuration>
和以下 .ci.config 文件
<?xml version="1.0"?>
<configuration
xmlns:patch="http://www.sitecore.net/xmlconfig/"
xmlns:set="http://www.sitecore.net/xmlconfig/set/"
xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
<sitecore>
<sc.variable name="dataFolder" xdt:Transform="Replace" xdt:Location="Match(name)" set:value="#{data.folder}" />
</sitecore>
</configuration>
这两个文件都位于文件夹 App_Config\Include
中如您所见,我已将转换文件中的变量设置为包含变量“{data.folder}”
在 Octopus 中,我创建了一个包部署步骤,并设置了以下功能:
- 自定义安装目录
- 配置变量
- 配置转换
- 替换文件中的变量
在文件中的替换变量中,我包含了目标文件
App_Config\Include\Z_Project.#{Octopus.Environment.Id}.config
我相信我已经正确地遵循了 http://docs.octopusdeploy.com/display/OD/Substitute+Variables+in+Files,但是当部署运行时。 .ci.config 文件中的变量未被设置。
我确定我犯了一个非常基本的错误,但我不知道我做错了什么
我需要什么来获取转换文件以使用来自 Octopus 的变量
听起来您的过程在步骤、变量等方面是正确的,但我认为 .ci.config 文件中的转换在预览转换后不正确。
结果是这样
<sitecore>
<sc.variable name="dataFolder" set:value="#{data.folder}"/>
</sitecore>
尝试使用
<sitecore>
<sc.variable name="dataFolder" xdt:Transform="Replace" xdt:Location="Match(name)">
<patch:attribute name="value">#{data.folder}</patch:attribute>
</sc.variable>
</sitecore>
运行 这通过 Slow Cheetah (Visual Studio Gallery) 正确执行转换,并且如果在 Octopus Deploy 中正确设置了其他所有内容,这应该在转换发生之前获得注入的值。
希望对您有所帮助