]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-11631 Add sonar.buildString to api/project_analyses/search response
authorJanos Gyerik <janos.gyerik@sonarsource.com>
Thu, 14 Mar 2019 15:17:12 +0000 (16:17 +0100)
committerSonarTech <sonartech@sonarsource.com>
Tue, 19 Mar 2019 19:21:27 +0000 (20:21 +0100)
server/sonar-server/src/main/java/org/sonar/server/projectanalysis/ws/SearchResponseBuilder.java
server/sonar-server/src/main/resources/org/sonar/server/projectanalysis/ws/search-example.json
server/sonar-server/src/test/java/org/sonar/server/projectanalysis/ws/SearchActionTest.java
sonar-ws/src/main/protobuf/ws-projectanalyses.proto

index 38ec5b06c3fdda8582b9871ca93700feeca97448..9801a104d25709d5675f0e3ad61af545f2951763 100644 (file)
@@ -85,6 +85,7 @@ class SearchResponseBuilder {
       .setManualNewCodePeriodBaseline(searchData.getManualBaseline().filter(dbAnalysis.getUuid()::equals).isPresent());
     ofNullable(dbAnalysis.getCodePeriodVersion()).ifPresent(builder::setCodePeriodVersion);
     ofNullable(dbAnalysis.getProjectVersion()).ifPresent(builder::setProjectVersion);
+    ofNullable(dbAnalysis.getBuildString()).ifPresent(builder::setBuildString);
 
     return builder;
   }
index 2bfe51ec26bcb625a86ece839f8d3266b7297d0e..a3197eb5d295f080fc95699504369524696bdb80 100644 (file)
@@ -8,8 +8,8 @@
     {
       "key": "A2",
       "date": "2016-12-12T17:12:45+0100",
-      "codePeriodVersion": "1.2.1",
-      "projectVersion": "1.2.1.423",
+      "projectVersion": "1.2.1",
+      "buildString": "1.2.1.423",
       "manualNewCodePeriodBaseline": false,
       "events": [
         {
@@ -27,8 +27,8 @@
     {
       "key": "A1",
       "date": "2016-12-11T17:12:45+0100",
-      "codePeriodVersion": "1.2",
-      "projectVersion": "1.2.0.322",
+      "projectVersion": "1.2",
+      "buildString": "1.2.0.322",
       "manualNewCodePeriodBaseline": true,
       "events": [
         {
@@ -47,8 +47,8 @@
     {
       "key": "P1",
       "date": "2015-11-11T10:00:00+0100",
-      "codePeriodVersion": "1.2",
-      "projectVersion": "1.2.0.321",
+      "projectVersion": "1.2",
+      "buildString": "1.2.0.321",
       "manualNewCodePeriodBaseline": false,
       "events": [
         {
index d2888642aad8609ccd5bf69be2b8677615941fcd..6e90ff4601662a7ae2a81e6573be5ac81ab19051 100644 (file)
@@ -125,15 +125,15 @@ public class SearchActionTest {
     userSession.addProjectPermission(UserRole.USER, project);
     SnapshotDto a1 = db.components().insertSnapshot(newAnalysis(project)
       .setUuid("A1").setCreatedAt(parseDateTime("2016-12-11T17:12:45+0100").getTime())
-      .setCodePeriodVersion("1.2").setProjectVersion("1.2.0.322")
+      .setProjectVersion("1.2").setBuildString("1.2.0.322")
     );
     SnapshotDto a2 = db.components().insertSnapshot(newAnalysis(project)
       .setUuid("A2").setCreatedAt(parseDateTime("2016-12-12T17:12:45+0100").getTime())
-      .setCodePeriodVersion("1.2.1").setProjectVersion("1.2.1.423")
+      .setProjectVersion("1.2.1").setBuildString("1.2.1.423")
     );
     SnapshotDto a3 = db.components().insertSnapshot(newAnalysis(project)
       .setUuid("P1").setCreatedAt(parseDateTime("2015-11-11T10:00:00+0100").getTime())
-      .setCodePeriodVersion("1.2").setProjectVersion("1.2.0.321"));
+      .setProjectVersion("1.2").setBuildString("1.2.0.321"));
     db.getDbClient().branchDao().insert(db.getSession(), newBranchDto(project, LONG)
       .setManualBaseline(a1.getUuid()));
     db.commit();
@@ -621,20 +621,20 @@ public class SearchActionTest {
   }
 
   @Test
-  public void populates_projectVersion_and_codePeriodVersion() {
+  public void populates_projectVersion_and_buildString() {
     ComponentDto project = db.components().insertPrivateProject();
     userSession.addProjectPermission(UserRole.USER, project);
     SnapshotDto[] analyses = new SnapshotDto[] {
-      db.components().insertSnapshot(newAnalysis(project).setCodePeriodVersion(null).setProjectVersion(null)),
-      db.components().insertSnapshot(newAnalysis(project).setCodePeriodVersion("a").setProjectVersion(null)),
-      db.components().insertSnapshot(newAnalysis(project).setCodePeriodVersion(null).setProjectVersion("b")),
-      db.components().insertSnapshot(newAnalysis(project).setCodePeriodVersion("c").setProjectVersion("d"))
+      db.components().insertSnapshot(newAnalysis(project).setProjectVersion(null).setBuildString(null)),
+      db.components().insertSnapshot(newAnalysis(project).setProjectVersion("a").setBuildString(null)),
+      db.components().insertSnapshot(newAnalysis(project).setProjectVersion(null).setBuildString("b")),
+      db.components().insertSnapshot(newAnalysis(project).setProjectVersion("c").setBuildString("d"))
     };
 
     SearchResponse result = call(project.getDbKey());
 
     assertThat(result.getAnalysesList())
-      .extracting(Analysis::getKey, Analysis::getCodePeriodVersion, Analysis::getProjectVersion)
+      .extracting(Analysis::getKey, Analysis::getProjectVersion, Analysis::getBuildString)
       .containsOnly(
         tuple(analyses[0].getUuid(), "", ""),
         tuple(analyses[1].getUuid(), "a", ""),
index d1a63b70b79629b6cf7d00aa20ef756302610242..891c5e52565d4d90ed067399c10932c67885a647 100644 (file)
@@ -59,6 +59,7 @@ message Analysis {
   optional string codePeriodVersion = 4;
   optional string projectVersion = 5;
   optional bool manualNewCodePeriodBaseline = 6;
+  optional string buildString = 7;
 }
 
 message QualityGate {