Last active
November 2, 2017 03:47
-
-
Save matt-hensley/128a094153d64ff5e230 to your computer and use it in GitHub Desktop.
MSBuild target to notify Rollbar of a publish. Requires RollbarSharp web.config entries and git on user's path.
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
<?xml version="1.0" encoding="utf-8"?> | |
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | |
<Target Name="NotifyRollbarOfDeploy" AfterTargets="MSDeployPublish;CopyAllFilesToSingleFolderForPackage"> | |
<XmlPeek XmlInputPath="$(_PackageTempDir)\web.config" | |
Query="//appSettings/add[@key='Rollbar.AccessToken']/@value"> | |
<Output TaskParameter="Result" ItemName="RollbarAccessToken" /> | |
</XmlPeek> | |
<XmlPeek XmlInputPath="$(_PackageTempDir)\web.config" | |
Query="//appSettings/add[@key='Rollbar.Environment']/@value"> | |
<Output TaskParameter="Result" ItemName="RollbarEnvironment" /> | |
</XmlPeek> | |
<Exec Command="git log -1 --format=%%H" ConsoleToMSBuild="true" EchoOff="true" WorkingDirectory="$(ProjectDir)\.."> | |
<Output TaskParameter="ConsoleOutput" PropertyName="GitSHA" /> | |
</Exec> | |
<Exec Command="git config user.email" ConsoleToMSBuild="true" EchoOff="true" WorkingDirectory="$(ProjectDir)\.."> | |
<Output TaskParameter="ConsoleOutput" PropertyName="GitEmail" /> | |
</Exec> | |
<Message Text="Rollbar.AccessToken: @(RollbarAccessToken)" Importance="Normal" /> | |
<Message Text="Rollbar.Environment: @(RollbarEnvironment)" Importance="Normal" /> | |
<Message Text="Git SHA: $(GitSHA)" Importance="Normal" /> | |
<Message Text="Rollbar: $(GitEmail) deployed @(RollbarEnvironment) revision $(GitSHA)" Importance="High" /> | |
<Exec Command="@powershell -NoProfile -ExecutionPolicy unrestricted -Command "(new-object net.webclient).UploadString('https://api.rollbar.com/api/1/deploy/', 'access_token=@(RollbarAccessToken)&environment=@(RollbarEnvironment)&revision=$(GitSHA)&local_username=$(GitEmail)')"" EchoOff="true" /> | |
</Target> | |
</Project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment