Welcome to the Inedo Forums! Check out the Forums Guide for help getting started.
If you are experiencing any issues with the forum software, please visit the Contact Form on our website and let us know!
Create new server in Otter using API
-
I am trying to create a new server in Otter using PowerShell and the guidance in the documentation. Since there is no example, it has complicated things in that the page (which I am using the name of the server I am trying to create) returns an error of "not found". The URL I am using is:
https://<my server's URL>/servers/create/<server name>>?key=<my api key>
I am passing a json body with the parameters as described in the documentation using PowerShell's Invoke-RestMethod Cmdlet with a method of Post. What is it that I need to do to create this server?
Product: BuildMaster
Version: 6.0.4
-
I believe your url should look like https://<my server's URL>/api/infrastructure/servers/create/<server name>?key=<my api key>
-
Hello Paul
Here is the powershell script we are using.
It is running from the server as a part of our init server script.
We deploy the Otter/BuildMaster Agent and we run the script .Hope this help
Regards
PhilippeParam( [Parameter(Mandatory=$false)] [string]$API = "https://#OTTERHOST#/api", [Parameter(Mandatory=$false)] [string]$SERVEUR = $env:computerName ) #end param # Extract AESKey [xml]$XmlDocument = Get-Content -Path "C:\Program Files\InedoAgent\InedoAgentService.exe.config" $AESKey=($XmlDocument.configuration.appsettings.add | where-object {$_.key -eq "EncryptionKey"}).value # # Grab list of registered server # $URI=$API+"/infrastructure/servers/list" $aListServer=Invoke-RestMethod -Method Post -Uri $URI -Headers @{'X-ApiKey' = '********************'} if ($aListServer.Name -contains $SERVEUR){ # # Mise à jour # $URI=$API+"/infrastructure/servers/update/"+$SERVEUR $body = @{ name="$SERVEUR"; hostname="$SERVEUR"; active=$true; serverType="windows"; port="46336"; encryptionType="AES"; encryptionKey=$AESKey } }else{ # # Creation # $URI=$API+"/infrastructure/servers/create/"+$SERVEUR $body = @{ name="$SERVEUR"; hostname="$SERVEUR"; serverType="windows"; active=$true; drift="automaticallyRemediate"; port="46336"; roles=@("Baseline"); environments=@("Integration"); encryptionType="AES"; encryptionKey=$AESKey } } # # Appel de l'API # Invoke-RestMethod -Method Post -ContentType 'application/json;' -Uri $URI -Body (ConvertTo-Json $body) -Headers @{'X-ApiKey' = '********************'} #