diff options
author | BenoƮt Gianinetti <benoit.gianinetti@sonarsource.com> | 2018-11-01 10:53:00 +0100 |
---|---|---|
committer | SonarTech <sonartech@sonarsource.com> | 2019-01-08 20:21:04 +0100 |
commit | ea906c4f2b2d9b404b141aeeebf5d54f5148bdcf (patch) | |
tree | 67cd8f666083f125f5cc190f2a81a88f0db3ab64 | |
parent | ba01aadcb02629042d8378473a9726d13679a938 (diff) | |
download | sonarqube-ea906c4f2b2d9b404b141aeeebf5d54f5148bdcf.tar.gz sonarqube-ea906c4f2b2d9b404b141aeeebf5d54f5148bdcf.zip |
SONAR-11421 Add sha1 to ProjectAnalysis
4 files changed, 23 insertions, 2 deletions
diff --git a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutor.java b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutor.java index 4556743b147..4e14bc38d18 100644 --- a/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutor.java +++ b/server/sonar-ce-task-projectanalysis/src/main/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutor.java @@ -125,7 +125,9 @@ public class PostProjectAnalysisTasksExecutor implements ComputationStepExecutor getAnalysis().map(a -> a.getDate().getTime()).orElse(system2.now()), ScannerContextImpl.from(reportReader.readContextProperties()), status == SUCCESS ? createQualityGate() : null, - createBranch()); + createBranch(), + reportReader.readMetadata().getScmRevisionId() + ); } @CheckForNull @@ -223,10 +225,11 @@ public class PostProjectAnalysisTasksExecutor implements ComputationStepExecutor private final Branch branch; @Nullable private final Analysis analysis; + private final String scmRevisionId; private ProjectAnalysisImpl(@Nullable Organization organization, CeTask ceTask, Project project, @Nullable Analysis analysis, long date, - ScannerContext scannerContext, @Nullable QualityGate qualityGate, @Nullable Branch branch) { + ScannerContext scannerContext, @Nullable QualityGate qualityGate, @Nullable Branch branch, String scmRevisionId) { this.organization = organization; this.ceTask = requireNonNull(ceTask, "ceTask can not be null"); this.project = requireNonNull(project, "project can not be null"); @@ -235,6 +238,7 @@ public class PostProjectAnalysisTasksExecutor implements ComputationStepExecutor this.scannerContext = requireNonNull(scannerContext, "scannerContext can not be null"); this.qualityGate = qualityGate; this.branch = branch; + this.scmRevisionId = scmRevisionId; } @Override @@ -284,6 +288,11 @@ public class PostProjectAnalysisTasksExecutor implements ComputationStepExecutor } @Override + public String getScmRevisionId() { + return scmRevisionId; + } + + @Override public String toString() { return "ProjectAnalysis{" + "ceTask=" + ceTask + diff --git a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java index e03fc741893..5ee2b694d31 100644 --- a/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java +++ b/server/sonar-ce-task-projectanalysis/src/test/java/org/sonar/ce/task/projectanalysis/api/posttask/PostProjectAnalysisTasksExecutorTest.java @@ -114,6 +114,8 @@ public class PostProjectAnalysisTasksExecutorTest { .setOrganizationsEnabled(new Random().nextBoolean()) .setOrganization(Organization.from( new OrganizationDto().setKey(organizationKey).setName(organizationName).setUuid(organizationUuid).setDefaultQualityGateUuid("foo"))); + + reportReader.setMetadata(ScannerReport.Metadata.newBuilder().build()); } @Test diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTask.java b/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTask.java index b89cbfdfd8a..ec1b4be349a 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTask.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTask.java @@ -122,5 +122,10 @@ public interface PostProjectAnalysisTask { * @since 6.1 */ ScannerContext getScannerContext(); + + /** + * Revision Id that has been analysed + */ + String getScmRevisionId(); } } diff --git a/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java b/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java index 35670ce5da8..c049497d2aa 100644 --- a/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java +++ b/sonar-plugin-api/src/main/java/org/sonar/api/ce/posttask/PostProjectAnalysisTaskTester.java @@ -782,6 +782,11 @@ public class PostProjectAnalysisTaskTester { } @Override + public String getScmRevisionId() { + return null; + } + + @Override public String toString() { return "ProjectAnalysis{" + "organization=" + organization + |