SLACK Notification proceess failing

Hello I am experiencing slack notification failure during deployment . see below the extract from the raw log file
| == Failed: Step 3: Slack - Notify Deployment - OneSpace ==
00:02:11 Fatal | The step failed: Activity Slack - Notify Deployment - OneSpace on the Octopus Server failed with error ‘The remote script failed with exit code 101’.
00:02:11 Verbose | Slack - Notify Deployment - OneSpace completed.
Slack Configuration is same with other projects that are working fine.

Hi @lemi.odidi,

Thanks for reaching out, I’d be happy to look into this error with your Notify Slack Step!

Are you able to please upload the task logs to our secure upload portal?

I’d also like to confirm that you are using the Notify Slack community Step Template and if there have been any changes made could you please also send through the deployment process JSON?

We have seen this once before were a recursive variable reference was the cause: The remote script failed with exit code 101 - #7 by garrett.dass

Ensure that recursive loops do not exist in the variable values

Feel free to reach out with any questions at all, looking forward to getting to the bottom of this!

Hello Finnian can you send the link to upload the task log again?

Hi @lemi.odidi,

The secure upload portal link in Finnian’s post is still available.

Are you having trouble accessing it?

Regards,
Paul

I was able to access it but unable to upload the task file

Tried it again and it worked
Task log file has been uploaded

Thanks for that.

I’m seeing this warning in the Slack step.

An attempt to parse the variable symbol "channel" appears to have resulted in a self referencing loop (channel -> channel). Ensure that recursive loops do not exist in the variable values.

It suggests that you have a variable value referencing itself, causing the step to fail.

How do you suggest I do this. I have compared all other projects to this and they have the same config. Infact this was cloned from another that is working?

I would guess that the problem variable is used in the Channel handle field within the Slack step.
Is that variable set as a Project variable or a Library set variable?
Is the value and scoping configured correctly?

You could try adding the OctopusPrintEvaluatedVariables system variable with a value of true to your project. This will output all variable values used by the steps and may highlight what the issue is.
After adding this variable, you would need to create a new release or update the variable snapshot for the current release.

It is a Library set variable

Ok…is the variable name within the Slack step the same as the variable name in the library set?
Is there a variable with the same name within the project possibly? Or in another variable set?

I’m wondering if there is any variable nesting occurring here, such as a project variable that has a value which points to a library variable etc

Ultimately, using printing the variable values to the deployment log may be necessary to see what is being evaluated for this one.

This is the script from the slack notification step of the project.
function Slack-Rich-Notification ($notification)
{
$payload = @{
channel = $OctopusParameters[‘Channel’]
username = $OctopusParameters[‘Username’];
icon_url = $OctopusParameters[‘IconUrl’];
attachments = @(
@{
fallback = $notification[“fallback”];
color = $notification[“color”];
fields = @(
@{
title = $notification[“title”];
title_link = $notification[“title_link”];
value = $notification[“value”];
});
};
);
}
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]‘Ssl3,Tls,Tls11,Tls12’
Invoke-RestMethod -Method POST -Body ($payload | ConvertTo-Json -Depth 4) -Uri $OctopusParameters[‘HookUrl’] -ContentType ‘application/json’
}

$IncludeMachineName = [boolean]::Parse($OctopusParameters[‘IncludeMachineName’]);
if ($IncludeMachineName) {
$MachineName = $OctopusParameters[‘Octopus.Machine.Name’];
if ($MachineName) {
$FormattedMachineName = “($MachineName)”;
}
}

if ($OctopusParameters[‘Octopus.Deployment.Error’] -eq $null){
Slack-Rich-Notification @{
title = “Success”;
title_link = “$OctopusWebBaseUrl$OctopusWebDeploymentLink”;
value = “Deploy <$OctopusWebBaseUrl$OctopusWebProjectLink|$OctopusProjectName> release <$OctopusWebBaseUrl$OctopusWebReleaseLink|$OctopusReleaseNumber> to $OctopusEnvironmentName $OctopusActionTargetRoles $OctopusDeploymentTenantName $FormattedMachineName”;
fallback = “Deployed $OctopusProjectName release $OctopusReleaseNumber to $OctopusEnvironmentName successfully”;
color = “good”;
};
} else {
Slack-Rich-Notification @{
title = “Failed”;
title_link = “$OctopusWebBaseUrl$OctopusWebDeploymentLink”;
value = “Deploy <$OctopusWebBaseUrl$OctopusWebProjectLink|$OctopusProjectName> release <$OctopusWebBaseUrl$OctopusWebReleaseLink|$OctopusReleaseNumber> to $OctopusEnvironmentName $OctopusActionTargetRoles $OctopusDeploymentTenantName $FormattedMachineName”;
fallback = “Failed to deploy $OctopusProjectName release $OctopusReleaseNumber to $OctopusEnvironmentName”;
color = “danger”;
};
}

is there anything wrong with this?

The step itself looks fine, but you need to check on the Channel variable to how it is being defined because Octopus is seeing somehow finding that $Channel = $Channel which is causing the error.

The test I mentioned earlier to print the variable values to the deployment log will show what value Octopus uses for the Channel variable and may help identify where it is getting that from.

Thanks Paul,
Do I need it to apply this settings across system or just for this specific project. FYI I have 73 different projects deployed to different environments and would prefer not to make changes system wide but to only the affected project

The issue has been fixed after making the correction in the variable set

1 Like

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.