Created
September 13, 2015 22:27
-
-
Save BrendanThompson/d57794855a81f026e613 to your computer and use it in GitHub Desktop.
Notify Slack of Octopus Deploy Status
This file contains hidden or 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
od_base="`get_octopusvariable "Octopus.Web.BaseUrl"`" | |
od_deployment_link="`get_octopusvariable "Octopus.Web.DeploymentLink"`" | |
od_deployment_name="`get_octopusvariable "Octopus.Deployment.Name"`" | |
od_deployer="`get_octopusvariable "Octopus.Deployment.CreatedBy.DisplayName"`" | |
od_project_name="`get_octopusvariable "Octopus.Project.Name"`" | |
od_project_link="`get_octopusvariable "Octopus.Web.ProjectLink"`" | |
od_release="`get_octopusvariable "Octopus.Release.Number"`" | |
od_release_link="`get_octopusvariable "Octopus.Web.ReleaseLink"`" | |
od_environment="`get_octopusvariable "Octopus.Environment.Name"`" | |
od_deployment_status="`get_octopusvariable "Octopus.Deployment.ErrorDetail"`" | |
od_return="" | |
slack_color="" | |
if [[ -z ${od_deployment_status} ]]; then | |
od_return="successfully" | |
slack_color="good" | |
else | |
od_return="unsuccessfully" | |
slack_color="danger" | |
fi | |
slack_payload=$(cat <<EOF | |
{ | |
"username": "OctopusDeploy", | |
"icon_url": "http://octopusdeploy.com/content/resources/favicon.png", | |
"channel": "#deploy", | |
"attachments": [ | |
{ | |
"fallback": "Deployed ${od_project_name} release ${od_release} to ${od_environment} ${od_return}.", | |
"color": "${slack_color}", | |
"title": "${od_project_name} - ${od_deployment_name}", | |
"title_link": "${od_base}${od_deployment_link}", | |
"text": "Deployed <${od_base}${od_project_link}|${od_project_name}> release <${od_base}${od_release_link}|${od_release}> to *${od_environment}* ${od_return}", | |
"fields": [ | |
{ | |
"title": "Deployed by", | |
"value": "${od_deployer}", | |
"short": true | |
}, | |
{ | |
"title": "Environment", | |
"value": "${od_environment}", | |
"short": true | |
} | |
], | |
"mrkdwn_in": ["text"] | |
} | |
] | |
} | |
EOF | |
) | |
curl -X POST --data-urlencode "payload=${slack_payload}" https://hooks.slack.com/services/XXX/YYYY |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment