Skip to content

Instantly share code, notes, and snippets.

@MacRusher
Created March 13, 2018 10:07
Show Gist options
  • Save MacRusher/a1778900ce72187c934bb4cfbd632723 to your computer and use it in GitHub Desktop.
Save MacRusher/a1778900ce72187c934bb4cfbd632723 to your computer and use it in GitHub Desktop.
Create backdated SonarQube analysis for a project
#!/usr/bin/env bash
# Prepare list of commit hashes.
# Adjust `since`, `grep` and other switches to your needs.
git log --merges --since=2018-02-01 --grep="(pull request #" --format="%H %ci" |
while read -a vars
do
# Checkout to given commit.
# Must be executed in the target repository, with no working three changes.
git checkout ${vars[0]}
# Performs analysis and publish it with the date of the commit.
# Assuming that sonar-project.properties is present and configured properly.
sonar-scanner -X -Dsonar.analysis.mode=publish -Dsonar.projectDate=${vars[1]}
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment