Created
October 30, 2014 02:16
-
-
Save DamianMac/a944c0fcab6db531e7a5 to your computer and use it in GitHub Desktop.
Executing a Script Task via the Octopus API
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var server = "http://yourserveraddress:8065/"; //Your server and IP address | |
var apiKey = "API-XXXXXXXXXXXXXXXXXXXXXXXXX"; // Get this from your 'profile' page in the Octopus web portal | |
var endpoint = new OctopusServerEndpoint(server, apiKey); | |
var repository = new OctopusRepository(endpoint); | |
var task = new Octopus.Client.Model.TaskResource(); | |
task.Name = "AdHocScript"; | |
task.Description = "Script invoked via API"; | |
task.Arguments.Add("MachineIds", new Object[]{"machines-129"}); //Your machine ID | |
task.Arguments.Add("ScriptBody", "Write-Host \"Hello World\""); //Or you'll probably want to read in a script body from disk | |
var result = repository.Tasks.Create(task); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment