我正在尝试通过 REST API 创建一台机器,并通过 PowerShell 调用它。
根据documentation ,只需要机器的名称和指纹即可创建机器。但我尝试的一切都会导致 405 或 500 错误:
$newMachine = @{Name='machineName';Thumbprint='asdvblsafghkvadc';} | ConvertTo-Json
$webClient.UploadString('http://server/octopus/api/machines','POST',$newMachine)
### OR
$newMachine = @{Name='machineName';Thumbprint='asdvblsafghkvadc';Roles='[web-server]';EnvironmentIds='[Environment-12]'; | ConvertTo-Json
$webClient.UploadString('http://server/octopus/api/machines','POST',$newMachine)
创建环境和编辑机器完美无缺,我就是无法让这台机器创建下来。
最佳答案
ShaneC提到的帖子现在有点旧了。我建议任何尝试在 Powershell 中执行此操作的人检查我开始为 Octopus Deploy 编写的模块。
模块站点:http://octoposh.net/
使用模块添加机器示例:https://github.com/Dalmirog/OctoPosh/wiki/Creating-Resources#machines
该模块仍在进行中,但我最近收到了很好的反馈。
在社区的一些帮助和反馈下,我相信它最终会变得非常好:)
关于api - 通过 REST API (PowerShell) 创建 Octopus 机器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31343342/