|
| 1 | +# Violation Comments to GitLab Plugin |
| 2 | + |
| 3 | +[](https://jenkins.ci.cloudbees.com/job/plugins/job/violation-comments-to-gitlab-plugin/) |
| 4 | + |
| 5 | +This is a Jenkins plugin for [Violation Comments to GitLab Lib](https://github.com/tomasbjerre/violation-comments-to-gitlab-lib). This plugin will find report files from static code analysis and comment GitLab pull requests with the content. |
| 6 | + |
| 7 | +You can have a look at [violations-test](https://gitlab.com/tomas.bjerre85/violations-test/merge_requests/1) to see what the result may look like. |
| 8 | + |
| 9 | +Available in Jenkins [here](https://wiki.jenkins-ci.org/display/JENKINS/Violation+Comments+to+GitLab+Plugin). |
| 10 | + |
| 11 | +You can get the variables you need from the [GitLab plugin](https://github.com/jenkinsci/gitlab-plugin) or [GitLab Merge Request Builder Plugin](https://github.com/timols/jenkins-gitlab-merge-request-builder-plugin). |
| 12 | + |
| 13 | +It supports: |
| 14 | + * [_AndoidLint_](http://developer.android.com/tools/help/lint.html) |
| 15 | + * [_Checkstyle_](http://checkstyle.sourceforge.net/) |
| 16 | + * [_ESLint_](https://github.com/sindresorhus/grunt-eslint) with `format: 'checkstyle'`. |
| 17 | + * [_PHPCS_](https://github.com/squizlabs/PHP_CodeSniffer) with `phpcs api.php --report=checkstyle`. |
| 18 | + * [_CLang_](https://clang-analyzer.llvm.org/) |
| 19 | + * [_RubyCop_](http://rubocop.readthedocs.io/en/latest/formatters/) with `rubycop -f clang file.rb` |
| 20 | + * [_CodeNarc_](http://codenarc.sourceforge.net/) |
| 21 | + * [_CPD_](http://pmd.sourceforge.net/pmd-4.3.0/cpd.html) |
| 22 | + * [_CPPLint_](https://github.com/theandrewdavis/cpplint) |
| 23 | + * [_CPPCheck_](http://cppcheck.sourceforge.net/) |
| 24 | + * [_CSSLint_](https://github.com/CSSLint/csslint) |
| 25 | + * [_Findbugs_](http://findbugs.sourceforge.net/) |
| 26 | + * [_Flake8_](http://flake8.readthedocs.org/en/latest/) |
| 27 | + * [_Pep8_](https://github.com/PyCQA/pycodestyle) |
| 28 | + * [_Mccabe_](https://pypi.python.org/pypi/mccabe) |
| 29 | + * [_PyFlakes_](https://pypi.python.org/pypi/pyflakes) |
| 30 | + * [_FxCop_](https://en.wikipedia.org/wiki/FxCop) |
| 31 | + * [_Gendarme_](http://www.mono-project.com/docs/tools+libraries/tools/gendarme/) |
| 32 | + * [_GoLint_](https://github.com/golang/lint) |
| 33 | + * [_GoVet_](https://golang.org/cmd/vet/) Same format as GoLint. |
| 34 | + * [_JSHint_](http://jshint.com/) |
| 35 | + * _Lint_ A common XML format, used by different linters. |
| 36 | + * [_JCReport_](https://github.com/jCoderZ/fawkez/wiki/JcReport) |
| 37 | + * [_MyPy_](https://pypi.python.org/pypi/mypy-lang) |
| 38 | + * [_PerlCritic_](https://github.com/Perl-Critic) |
| 39 | + * [_PiTest_](http://pitest.org/) |
| 40 | + * [_PyDocStyle_](https://pypi.python.org/pypi/pydocstyle) |
| 41 | + * [_PyLint_](https://www.pylint.org/) |
| 42 | + * [_PMD_](https://pmd.github.io/) |
| 43 | + * [_PHPPMD_](https://phpmd.org/) with `phpmd api.php xml ruleset.xml`. |
| 44 | + * [_ReSharper_](https://www.jetbrains.com/resharper/) |
| 45 | + * [_Simian_](http://www.harukizaemon.com/simian/) |
| 46 | + * [_StyleCop_](https://stylecop.codeplex.com/) |
| 47 | + * [_XMLLint_](http://xmlsoft.org/xmllint.html) |
| 48 | + * [_ZPTLint_](https://pypi.python.org/pypi/zptlint) |
| 49 | + |
| 50 | + |
| 51 | +# Screenshots |
| 52 | + |
| 53 | + |
| 54 | + |
| 55 | +## Job DSL Plugin |
| 56 | + |
| 57 | +This plugin can be used with the Job DSL Plugin. |
| 58 | + |
| 59 | +``` |
| 60 | +job('example') { |
| 61 | + publishers { |
| 62 | + violationsToGitLabRecorder { |
| 63 | + config { |
| 64 | + gitLabUrl("https://gitlab.com/") |
| 65 | + projectId(123) |
| 66 | + mergeRequestId(456) |
| 67 | +
|
| 68 | + commentOnlyChangedContent(true) |
| 69 | + createCommentWithAllSingleFileComments(true) |
| 70 | +
|
| 71 | + useApiToken(true) |
| 72 | + apiToken("") |
| 73 | + useApiTokenCredentials(false) |
| 74 | + apiTokenCredentialsId("id") |
| 75 | + apiTokenPrivate(true) |
| 76 | + authMethodHeader(true) |
| 77 | + ignoreCertificateErrors(true) |
| 78 | +
|
| 79 | + violationConfigs { |
| 80 | + violationConfig { |
| 81 | + reporter("FINDBUGS") |
| 82 | + pattern(".*/findbugs/.*\\.xml\$") |
| 83 | + } |
| 84 | + } |
| 85 | + } |
| 86 | + } |
| 87 | + } |
| 88 | +} |
| 89 | +``` |
| 90 | + |
| 91 | +## Pipeline Plugin |
| 92 | + |
| 93 | +This plugin can be used with the Pipeline Plugin: |
| 94 | + |
| 95 | +``` |
| 96 | +node { |
| 97 | +
|
| 98 | + checkout([ |
| 99 | + $class: 'GitSCM', |
| 100 | + branches: [[ name: '*/master' ]], |
| 101 | + doGenerateSubmoduleConfigurations: false, |
| 102 | + extensions: [], |
| 103 | + submoduleCfg: [], |
| 104 | + userRemoteConfigs: [[ url: 'https://gitlab.com/tomas.bjerre85/violations-test.git' ]] |
| 105 | + ]) |
| 106 | +
|
| 107 | + sh ''' |
| 108 | + ./gradlew build |
| 109 | + ''' |
| 110 | +
|
| 111 | + step([ |
| 112 | + $class: 'ViolationsToGitLabRecorder', |
| 113 | + config: [ |
| 114 | + gitLabUrl: 'https://gitlab.com/', |
| 115 | + projectId: 123, |
| 116 | + mergeRequestId: 456, |
| 117 | +
|
| 118 | + commentOnlyChangedContent: true, |
| 119 | + createCommentWithAllSingleFileComments: true, |
| 120 | +
|
| 121 | + useApiToken: true, |
| 122 | + apiToken: '', |
| 123 | + useApiTokenCredentials: false, |
| 124 | + apiTokenCredentialsId: 'id', |
| 125 | + apiTokenPrivate: true, |
| 126 | + authMethodHeader: true, |
| 127 | + ignoreCertificateErrors: true, |
| 128 | +
|
| 129 | + violationConfigs: [ |
| 130 | + [ pattern: '.*/checkstyle/.*\\.xml$', reporter: 'CHECKSTYLE' ], |
| 131 | + [ pattern: '.*/findbugs/.*\\.xml$', reporter: 'FINDBUGS' ], |
| 132 | + ] |
| 133 | + ] |
| 134 | + ]) |
| 135 | +} |
| 136 | +``` |
| 137 | + |
| 138 | +# Plugin development |
| 139 | +More details on Jenkins plugin development is available [here](https://wiki.jenkins-ci.org/display/JENKINS/Plugin+tutorial). |
| 140 | + |
| 141 | +There is a ```/build.sh``` that will perform a full build and test the plugin. You may have a look at sandbox/settings.xml on how to configure your Maven settings. |
| 142 | + |
| 143 | +A release is created like this. You need to clone from jenkinsci-repo, with https and have username/password in settings.xml. |
| 144 | +``` |
| 145 | +mvn release:prepare release:perform |
| 146 | +``` |
0 commit comments