-
-
Notifications
You must be signed in to change notification settings - Fork 491
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for Bitbucket Cloud Code Insights
This commit provides support for the newly created bitbucket cloud code insights API endpoints. The implementation has been done under the consideration that in newer versions no dedicated ALM support for bitbucket cloud exists, thus this implementation is minimal invasive. One thing to note here: * For local testing the link has to be set manually to a non localhost URL since bitbuckets API doesn't support it.
- Loading branch information
Marvin Wichmann
committed
Jun 7, 2020
1 parent
24bb830
commit 62c8687
Showing
25 changed files
with
935 additions
and
169 deletions.
There are no files selected for viewing
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
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
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
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
62 changes: 62 additions & 0 deletions
62
...hub/mc1arke/sonarqube/plugin/ce/pullrequest/bitbucket/client/AbstractBitbucketClient.java
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright (C) 2020 Marvin Wichmann | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU Lesser General Public | ||
* License as published by the Free Software Foundation; either | ||
* version 3 of the License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with this program; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
* | ||
*/ | ||
package com.github.mc1arke.sonarqube.plugin.ce.pullrequest.bitbucket.client; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import com.fasterxml.jackson.databind.DeserializationFeature; | ||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.github.mc1arke.sonarqube.plugin.ce.pullrequest.UnifyConfiguration; | ||
import com.github.mc1arke.sonarqube.plugin.ce.pullrequest.bitbucket.BitbucketServerPullRequestDecorator; | ||
import com.github.mc1arke.sonarqube.plugin.ce.pullrequest.bitbucket.client.model.server.ErrorResponse; | ||
import okhttp3.Response; | ||
|
||
import java.io.IOException; | ||
|
||
abstract class AbstractBitbucketClient { | ||
private UnifyConfiguration configuration; | ||
|
||
ObjectMapper getObjectMapper() { | ||
return new ObjectMapper() | ||
.setSerializationInclusion(JsonInclude.Include.NON_NULL) | ||
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES); | ||
} | ||
|
||
String baseUrl() { | ||
return configuration.getRequiredProperty(BitbucketServerPullRequestDecorator.PULL_REQUEST_BITBUCKET_URL); | ||
} | ||
|
||
String getToken() { | ||
return configuration.getRequiredProperty(BitbucketServerPullRequestDecorator.PULL_REQUEST_BITBUCKET_TOKEN); | ||
} | ||
|
||
void validate(Response response) throws IOException { | ||
if (!response.isSuccessful()) { | ||
ErrorResponse errors = null; | ||
if (response.body() != null) { | ||
errors = getObjectMapper().reader().forType(ErrorResponse.class) | ||
.readValue(response.body().string()); | ||
} | ||
throw new BitbucketException(response.code(), errors); | ||
} | ||
} | ||
|
||
public void setConfiguration(UnifyConfiguration configuration) { | ||
this.configuration = configuration; | ||
} | ||
} |
Oops, something went wrong.