Skip to content
This repository has been archived by the owner on Mar 2, 2024. It is now read-only.

Commit

Permalink
gitlab4j-api
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasbjerre committed Mar 4, 2019
1 parent dd45e2d commit 445e3e2
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 23 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@

Changelog of Violation comments to gitlab gradle plugin.

## Unreleased
### No issue

**gitlab4j-api**


[d0c6f9c2a8a5b57](https://github.com/tomasbjerre/violation-comments-to-gitlab-gradle-plugin/commit/d0c6f9c2a8a5b57) Tomas Bjerre *2019-02-19 20:22:23*


## 1.25
### No issue

Expand Down
20 changes: 14 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ A number of **parsers** have been implemented. Some **parsers** can parse output
| [_Checkstyle_](http://checkstyle.sourceforge.net/) | `CHECKSTYLE` |
| [_CodeNarc_](http://codenarc.sourceforge.net/) | `CODENARC` |
| [_Detekt_](https://github.com/arturbosch/detekt) | `CHECKSTYLE` | With `--output-format xml`.
| [_ERB_](https://www.puppetcookbook.com/posts/erb-template-validation.html) | `CLANG` | With `erb -P -x -T '-' "${it}" \| ruby -c 2>&1 >/dev/null \| grep '^-' \| sed -E 's/^-([a-zA-Z0-9:]+)/${filename}\1 ERROR:/p' > erbfiles.out`.
| [_DocFX_](http://dotnet.github.io/docfx/) | `DOCFX` |
| [_Doxygen_](https://www.stack.nl/~dimitri/doxygen/) | `CLANG` |
| [_ERB_](https://www.puppetcookbook.com/posts/erb-template-validation.html) | `CLANG` | With `erb -P -x -T '-' "${it}" \| ruby -c 2>&1 >/dev/null \| grep '^-' \| sed -E 's/^-([a-zA-Z0-9:]+)/${filename}\1 ERROR:/p' > erbfiles.out`.
| [_ESLint_](https://github.com/sindresorhus/grunt-eslint) | `CHECKSTYLE` | With `format: 'checkstyle'`.
| [_Findbugs_](http://findbugs.sourceforge.net/) | `FINDBUGS` |
| [_Flake8_](http://flake8.readthedocs.org/en/latest/) | `FLAKE8` |
Expand All @@ -35,6 +35,7 @@ A number of **parsers** have been implemented. Some **parsers** can parse output
| [_GoLint_](https://github.com/golang/lint) | `GOLINT` |
| [_GoVet_](https://golang.org/cmd/vet/) | `GOLINT` | Same format as GoLint.
| [_GoogleErrorProne_](https://github.com/google/error-prone) | `GOOGLEERRORPRONE` |
| [_IAR_](https://www.iar.com/iar-embedded-workbench/) | `IAR` | With `--no_wrap_diagnostics`
| [_Infer_](http://fbinfer.com/) | `PMD` | Facebook Infer. With `--pmd-xml`.
| [_JCReport_](https://github.com/jCoderZ/fawkez/wiki/JcReport) | `JCREPORT` |
| [_JSHint_](http://jshint.com/) | `JSHINT` |
Expand All @@ -43,6 +44,7 @@ A number of **parsers** have been implemented. Some **parsers** can parse output
| [_KotlinGradle_](https://github.com/JetBrains/kotlin) | `KOTLINGRADLE` | Output from Kotlin Gradle Plugin.
| [_KotlinMaven_](https://github.com/JetBrains/kotlin) | `KOTLINMAVEN` | Output from Kotlin Maven Plugin.
| [_Lint_]() | `LINT` | A common XML format, used by different linters.
| [_MSCpp_](https://visualstudio.microsoft.com/vs/features/cplusplus/) | `MSCPP` |
| [_Mccabe_](https://pypi.python.org/pypi/mccabe) | `FLAKE8` |
| [_MyPy_](https://pypi.python.org/pypi/mypy-lang) | `MYPY` |
| [_NullAway_](https://github.com/uber/NullAway) | `GOOGLEERRORPRONE` | Same format as Google Error Prone.
Expand All @@ -60,6 +62,7 @@ A number of **parsers** have been implemented. Some **parsers** can parse output
| [_ReSharper_](https://www.jetbrains.com/resharper/) | `RESHARPER` |
| [_RubyCop_](http://rubocop.readthedocs.io/en/latest/formatters/) | `CLANG` | With `rubycop -f clang file.rb`
| [_SbtScalac_](http://www.scala-sbt.org/) | `SBTSCALAC` |
| [_Scalastyle_](http://www.scalastyle.org/) | `CHECKSTYLE` |
| [_Simian_](http://www.harukizaemon.com/simian/) | `SIMIAN` |
| [_Spotbugs_](https://spotbugs.github.io/) | `FINDBUGS` |
| [_StyleCop_](https://stylecop.codeplex.com/) | `STYLECOP` |
Expand All @@ -72,15 +75,14 @@ A number of **parsers** have been implemented. Some **parsers** can parse output
Missing a format? Open an issue [here](https://github.com/tomasbjerre/violations-lib/issues)!

## Usage ##
There is a running example [here](https://github.com/tomasbjerre/violation-comments-to-gitlab-gradle-plugin/tree/master/violation-comments-to-gitlab-gradle-plugin-example).
There is a running example [here](/violation-comments-to-gitlab-gradle-plugin-example) and it is invoked [here](/build.sh).

Here is and example:

```
``
buildscript {
repositories {
maven { url 'https://plugins.gradle.org/m2/' }
maven { url 'https://jitpack.io' }
}
dependencies {
classpath "se.bjurr.violations:violation-comments-to-gitlab-gradle-plugin:X"
Expand All @@ -99,14 +101,20 @@ task violationCommentsToGitLab(type: se.bjurr.violations.comments.gitlab.plugin.
createSingleFileComments = true;
keepOldComments = false;
minSeverity = "INFO";
//commentTemplate = """
// See https://github.com/tomasbjerre/violation-comments-lib
//"""

apiTokenPrivate = true;
apiToken = System.properties['GITLAB_APITOKEN'];
authMethodHeader = true;
ignoreCertificateErrors = true;

shouldSetWip = false;

//proxyServer = ""
//proxyUser = ""
//proxyPassword = ""

violations = [
["FINDBUGS", ".", ".*/findbugs/.*\\.xml\$", "Findbugs"],
["PMD", ".", ".*/pmd/.*\\.xml\$", "PMD"],
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ apply from: project.buildscript.classLoader.getResource('gradle-plugin.gradle').
apply from: project.buildscript.classLoader.getResource('violations.gradle').toURI()

dependencies {
compile 'se.bjurr.violations:violation-comments-to-gitlab-lib:1.56'
compile 'se.bjurr.violations:violation-comments-to-gitlab-lib:1.66'
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,12 @@
package se.bjurr.violations.comments.gitlab.plugin.gradle;

import static org.gitlab.api.AuthMethod.HEADER;
import static org.gitlab.api.AuthMethod.URL_PARAMETER;
import static org.gitlab.api.TokenType.ACCESS_TOKEN;
import static org.gitlab.api.TokenType.PRIVATE_TOKEN;
import static se.bjurr.violations.comments.gitlab.lib.ViolationCommentsToGitLabApi.violationCommentsToGitLabApi;
import static se.bjurr.violations.lib.ViolationsApi.violationsApi;
import static se.bjurr.violations.lib.model.SEVERITY.INFO;

import java.util.ArrayList;
import java.util.List;
import org.gitlab.api.AuthMethod;
import org.gitlab.api.TokenType;
import org.gitlab4j.api.Constants.TokenType;
import org.gradle.api.DefaultTask;
import org.gradle.api.tasks.TaskAction;
import org.gradle.api.tasks.TaskExecutionException;
Expand All @@ -32,11 +27,13 @@ public class ViolationCommentsToGitLabTask extends DefaultTask {
private String mergeRequestIid;
private Boolean ignoreCertificateErrors = true;
private Boolean apiTokenPrivate = true;
private Boolean authMethodHeader = true;
private SEVERITY minSeverity = INFO;
private Boolean keepOldComments = false;
private Boolean shouldSetWip = false;
private String commentTemplate;
private String proxyServer;
private String proxyUser;
private String proxyPassword;

public void setCommentOnlyChangedContent(final boolean commentOnlyChangedContent) {
this.commentOnlyChangedContent = commentOnlyChangedContent;
Expand Down Expand Up @@ -75,10 +72,6 @@ public void setApiTokenPrivate(final Boolean apiTokenPrivate) {
this.apiTokenPrivate = apiTokenPrivate;
}

public void setAuthMethodHeader(final Boolean authMethodHeader) {
this.authMethodHeader = authMethodHeader;
}

public void setMinSeverity(final SEVERITY minSeverity) {
this.minSeverity = minSeverity;
}
Expand All @@ -99,6 +92,18 @@ public void setCommentTemplate(final String commentTemplate) {
this.commentTemplate = commentTemplate;
}

public void setProxyServer(final String proxyServer) {
this.proxyServer = proxyServer;
}

public void setProxyUser(final String proxyUser) {
this.proxyUser = proxyUser;
}

public void setProxyPassword(final String proxyPassword) {
this.proxyPassword = proxyPassword;
}

@TaskAction
public void gitChangelogPluginTasks() throws TaskExecutionException {
getProject().getExtensions().findByType(ViolationCommentsToGitLabPluginExtension.class);
Expand Down Expand Up @@ -134,24 +139,25 @@ public void gitChangelogPluginTasks() throws TaskExecutionException {
}

try {
final TokenType tokenType = apiTokenPrivate ? PRIVATE_TOKEN : ACCESS_TOKEN;
final AuthMethod authMethod = authMethodHeader ? HEADER : URL_PARAMETER;
final TokenType tokenType = apiTokenPrivate ? TokenType.PRIVATE : TokenType.ACCESS;
final Integer mergeRequestIidInteger = Integer.parseInt(mergeRequestIid);
violationCommentsToGitLabApi() //
.setHostUrl(gitLabUrl) //
.setProjectId(projectId) //
.setMergeRequestIid(mergeRequestIidInteger) //
.setApiToken(apiToken) //
.setTokenType(tokenType) //
.setMethod(authMethod) //
.setCommentOnlyChangedContent(commentOnlyChangedContent) //
.setCreateCommentWithAllSingleFileComments(createCommentWithAllSingleFileComments) //
.setCreateSingleFileComments(createSingleFileComments) //
.setIgnoreCertificateErrors(ignoreCertificateErrors) //
.setViolations(allParsedViolations) //
.setShouldKeepOldComments(keepOldComments) //
.setShouldSetWIP(shouldSetWip) //
.withCommentTemplate(commentTemplate) //
.setCommentTemplate(commentTemplate) //
.setProxyServer(proxyServer) //
.setProxyUser(proxyUser) //
.setProxyPassword(proxyPassword) //
.toPullRequest();
} catch (final Exception e) {
getLogger().error("", e);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,19 @@ task violationCommentsToGitLab(type: se.bjurr.violations.comments.gitlab.plugin.
createSingleFileComments = true;
keepOldComments = false;
minSeverity = "INFO";
//commentTemplate = """
// See https://github.com/tomasbjerre/violation-comments-lib
//"""

apiTokenPrivate = true;
apiToken = System.properties['GITLAB_APITOKEN'];
authMethodHeader = true;
ignoreCertificateErrors = true;

shouldSetWip = false;

//proxyServer = ""
//proxyUser = ""
//proxyPassword = ""

violations = [
["FINDBUGS", ".", ".*/findbugs/.*\\.xml\$", "Findbugs"],
Expand Down

0 comments on commit 445e3e2

Please sign in to comment.