【问题标题】:Prevent Octopus from Running a Deployment Script防止 Octopus 运行部署脚本
【发布时间】:2016-10-07 19:42:10
【问题描述】:

我正在部署一个包含 deploy.ps1 文件的包。您已经知道 Octopus 默认为 running this script on deploying,我想防止它发生并运行自定义脚本。

【问题讨论】:

  • 你为什么要这样做,你能重命名脚本文件吗?
  • 在我的情况下,Deploy.ps1 在部署目标上启动我的包中的所有服务。这是大多数目标服务器的默认行为,除了一个,只需要启动其中一项服务。我想改用自定义脚本。
  • 从该特定项目中删除 deploy.ps1 脚本并在 Octopus 步骤本身中运行部署 powershell 脚本不是更干净的方法吗?

标签: octopus-deploy


【解决方案1】:

如果您有这样的需求,那么最好将启动服务的 powershell 移动到单独的构建步骤,然后标记您希望该脚本在其上运行的触手。

在服务的部署步骤中,将启动模式设置为“手动”

然后有一个启动服务的步骤,并将该脚本的范围限定为您要自动启动的环境/服务器

我这里使用的步骤模板的代码是

{
  "Id": "ActionTemplates-1",
  "Name": "Enable and start service",
  "Description": null,
  "ActionType": "Octopus.Script",
  "Version": 8,
  "Properties": {
    "Octopus.Action.Package.NuGetFeedId": "feeds-builtin",
    "Octopus.Action.Script.Syntax": "PowerShell",
    "Octopus.Action.Script.ScriptSource": "Inline",
    "Octopus.Action.RunOnServer": "false",
    "Octopus.Action.Script.ScriptBody": "$serviceName = $OctopusParameters[\"ServiceName\"]\n\nwrite-host \"the service is: \" $serviceName\n\n& \"sc.exe\" config $serviceName start= delayed-auto\n& \"sc.exe\" start $serviceName\n\n"
  },
  "Parameters": [
    {
      "Name": "ServiceName",
      "Label": "Service Name",
      "HelpText": null,
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "$Meta": {
    "ExportedAt": "2016-10-10T10:21:21.980Z",
    "OctopusVersion": "3.3.2",
    "Type": "ActionTemplate"
  }
}

您可能需要修改步骤模板,因为它将服务设置为“自动 - 延迟”,然后启动服务。

【讨论】:

    【解决方案2】:

    你能把脚本移动到子文件夹吗?

    These scripts must be located in the root of your package

    http://docs.octopusdeploy.com/display/OD/Custom+scripts

    或者 - 如果永远不应该部署您的 deploy.ps1 脚本,请不要在部署包中包含它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-01-25
      • 1970-01-01
      • 1970-01-01
      • 2019-07-17
      • 1970-01-01
      • 1970-01-01
      • 2014-01-23
      相关资源
      最近更新 更多