Created
September 21, 2011 22:42
-
-
Save dandean/1233535 to your computer and use it in GitHub Desktop.
Check for build failure before allowing a commit on a VisualStudio project
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
| #!/bin/sh | |
| # | |
| # This script builds the project before a commit takes place. If the build | |
| # fails, the commit is rejected and the build log is printed. | |
| echo "Building solution..." | |
| # Build the solution in Release mode... | |
| LOG=`/c/Windows/Microsoft.NET/Framework/v3.5/MSBuild.exe "/property:Configuration=Release" "/verbosity:n" "/target:Clean;Rebuild"` | |
| # Check the build log for the string "Build FAILED"... | |
| if [[ "$LOG" == *Build\ FAILED* ]] | |
| then | |
| # Build failed. Notify the developer and print the log... | |
| echo "+------------------------------------------------------------------------------+" | |
| echo "| Build FAILED. Commit Aborted. |" | |
| echo "+------------------------------------------------------------------------------+" | |
| echo $LOG | |
| echo "+------------------------------------------------------------------------------+" | |
| echo "| Build FAILED. Commit Aborted. <EOM> |" | |
| echo "+------------------------------------------------------------------------------+" | |
| # Exit with 1 so that the commit is denied... | |
| exit 1 | |
| fi | |
| # Build succeeded. Exit with 0 so that the commit is applied. | |
| echo "Build Succeeded" | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment