在八达通中自动安排未来的部署

Automatically schedule future deployment in Octopus

更新:我发现在 version 3.3 中现在可以在章鱼服务器上执行脚本了,我还没有更新我的章鱼,但我认为它会按设计工作。我仍然想知道如果没有 octo.exe?

是否有更好的方法

我要完成的任务是在每次成功部署生产后,自动安排 DR 部署在接下来的 24 小时内发生。

我想要的方法是让章鱼来做。

我在部署结束时添加了一个新的章鱼步骤,仅在上一步成功后 运行 秒。我尝试使用 octo deploy-release --deployAt 可以在新创建的步骤中找到 here

我的挑战是,脚本步骤需要我选择一个目标角色,这意味着它将在触手上执行。此外,需要 Octo.exe 的存在。

我尝试创建自己的章鱼步骤模板,但在我的自定义步骤中仍然需要部署目标角色。

{
  "Id": "ActionTemplates-2",
  "Name": "Octopus - Schedule Deployment",
  "Description": "Schedule a future octopus deployment",
  "ActionType": "Octopus.Script",
  "Version": 3,
  "Properties": {
    "Octopus.Action.Script.Syntax": "PowerShell",
    "Octopus.Action.Script.ScriptBody": "--hide--"
  },
  "SensitiveProperties": {},
  "Parameters": [
    {
      "Name": "OctoPath",
      "Label": "Path for Octo.exe",
      "HelpText": "Location for octo.exe",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "projName",
      "Label": "Project Name",
      "HelpText": "The name of the project should be deployed",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "days",
      "Label": "Days",
      "HelpText": "The days in future this deployment would happen",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "hours",
      "Label": "Hours",
      "HelpText": "The hours in future this deployment would happen",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    },
    {
      "Name": "env",
      "Label": "Environment to deploy",
      "HelpText": "The environment next deployment should happen",
      "DefaultValue": null,
      "DisplaySettings": {
        "Octopus.ControlType": "SingleLineText"
      }
    }
  ],
  "$Meta": {
    "ExportedAt": "2016-04-20T13:58:54.263Z",
    "OctopusVersion": "3.2.0",
    "Type": "ActionTemplate"
  }
}

有没有办法改变模板以摆脱角色选择并让章鱼服务器直接执行它,就像它对 Azure 脚本步骤所做的那样?

有没有其他方法可以让章鱼服务器在没有外部帮助的情况下自动安排部署?我想这又回到了第一个问题,我可能仍然需要章鱼来 运行 服务器端的东西。

注意:我们手动启动生产部署,因此我没有其他工具等待部署响应。我认为可以让一个流程定期调出最后的部署并进行一些分析,然后相应地安排新的部署,但这不像章鱼直接执行的那样干净。完全不需要将 octo.exe 注入随机生产机器

您可以在 C# 中创建新的 WebAPI 项目,拉入 Octopus.Deploy nuget 包,

编写接受 HTTP 请求并处理调度逻辑的代码。

将该项目托管在与 Octopus 服务器本身相同的服务器上。在 IIS 中设置网站应该需要 20-30 分钟。

在您的部署过程中,添加创建 http 请求的步骤,然后完成。您甚至可以更进一步,让 site/service 监听每一次成功的部署,并据此做出决策,这样其他项目就不必在章鱼部署过程中添加额外的步骤。

如您所说,轮询也是一种可行的选择。

或者,如果您使用的是 Octopus 部署 3.0,它们已经公开了 REST API,我不确定它是否足够强大以允许您创建计划部署,但您可以探索一下:https://github.com/OctopusDeploy/OctopusDeploy-Api/wiki/Releases

我同意在生产服务器中浮动 octo.exe 是个坏主意。它可能会不同步,您的生产服务器不应该处理这个问题。