使用Octopus Deploy 3在.config文件中进行变量替换

时间:2016-03-15 14:47:18

标签: octopus-deploy config-transformation

我正在使用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

正如您所看到的,我已在变换文件中设置变量以包含变量&#34; {data.folder}&#34;

在Octopus中,我创建了一个包部署步骤,并设置了以下功能:

  • 自定义安装目录
  • 配置变量
  • 配置转换
  • 替换文件中的变量

在文件中的替换变量中,我包含了目标文件

APP_CONFIG \包括\ Z_Project。#{Octopus.Environment.Id}的.config

我相信我已正确地遵循http://docs.octopusdeploy.com/display/OD/Substitute+Variables+in+Files,但是在部署运行时。 .ci.config文件中的变量未设置。

我确信我犯了一个非常基本的错误,但我不知道我做错了什么

我需要什么才能让转换文件使用Octopus中的变量

1 个答案:

答案 0 :(得分:0)

听起来你的步骤,变量等方面的过程是正确的,但我不认为在预览转换后.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中,这应该在转换发生之前注入值。

希望这有帮助

相关问题