Hi, I’m trying to output the username of who triggered a runbook in a Powershell script, on Octopus 2020.04.
I’m trying to use $OctopusParameters[‘Octopus.Account.Username’] but this appears to be blank in runbooks, but set for the project?
Here’s the script:
$username = $OctopusParameters['Octopus.Account.Username']
$hostname = $OctopusParameters['Octopus.Machine.Name']
$link = "https://octopus" + $OctopusParameters["Octopus.Web.RunbookSnapshotLink"]
$payload = @{
channel = $OctopusParameters['slack_channel'];
attachments = @(
@{
color = "good";
fields = @(
@{
title = "Production config updated";
value = "$username updated configuration on $hostname, see $link";
});
};
);
}
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
Invoke-RestMethod -Method POST -Proxy $proxy -Body ($payload | ConvertTo-Json -Depth 4) -Uri $OctopusParameters['slack_webhook_url'] -ContentType 'application/json'
The output of this is " updated configuration on , see https://octopus/app#/Spaces…"
Thanks