Git Product home page Git Product logo

violation-comments-to-stash-plugin's Introduction

Violation Comments to Bitbucket Server

It comments pull requests in Bitbucket Server (or Stash) with violations found in report files from static code analysis.

It uses Violation Comments to Bitbucket Server Lib and supports the same formats as Violations Lib.

Example of supported reports are available here.

Note: Using Bitbucket Cloud? You may have a look at Violation Comments to Bitbucket Cloud Command Line. This will only work with Bitbucket Server.

You can also do this with a command line tool.

A number of parsers have been implemented. Some parsers can parse output from several reporters.

Reporter Parser Notes
ARM-GCC CLANG
AndroidLint ANDROIDLINT
Ansible-Later ANSIBLELATER With json format
AnsibleLint FLAKE8 With -p
Bandit CLANG With bandit -r examples/ -f custom -o bandit.out --msg-template "{abspath}:{line}: {severity}: {test_id}: {msg}"
CLang CLANG
CPD CPD
CPPCheck CPPCHECK With cppcheck test.cpp --output-file=cppcheck.xml --xml
CPPLint CPPLINT
CSSLint CSSLINT
Checkstyle CHECKSTYLE
CloudFormation Linter JUNIT cfn-lint . -f junit --output-file report-junit.xml
CodeClimate CODECLIMATE
CodeNarc CODENARC
Coverity COVERITY
Dart MACHINE With dart analyze --format=machine
Dependency Check SARIF Using --format SARIF
Detekt CHECKSTYLE With --output-format xml.
DocFX DOCFX
Doxygen CLANG
ERB 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 CHECKSTYLE With format: 'checkstyle'.
Findbugs FINDBUGS
Flake8 FLAKE8
FxCop FXCOP
GCC CLANG
GHS GHS
Gendarme GENDARME
Generic reporter GENERIC Will create one single violation with all the content as message.
GoLint GOLINT
GoVet GOLINT Same format as GoLint.
GolangCI-Lint CHECKSTYLE With --out-format=checkstyle.
GoogleErrorProne GOOGLEERRORPRONE
HadoLint CHECKSTYLE With -f checkstyle
IAR IAR With --no_wrap_diagnostics
Infer PMD Facebook Infer. With --pmd-xml.
JACOCO JACOCO
JCReport JCREPORT
JSHint JSLINT With --reporter=jslint or the CHECKSTYLE parser with --reporter=checkstyle
JUnit JUNIT It only contains the failures.
KTLint CHECKSTYLE
Klocwork KLOCWORK
KotlinGradle KOTLINGRADLE Output from Kotlin Gradle Plugin.
KotlinMaven KOTLINMAVEN Output from Kotlin Maven Plugin.
Lint LINT A common XML format, used by different linters.
MSBuildLog MSBULDLOG With -fileLogger use .*msbuild\\.log$ as pattern or -fl -flp:logfile=MyProjectOutput.log;verbosity=diagnostic for a custom output filename
MSCpp MSCPP
Mccabe FLAKE8
MyPy MYPY
NullAway GOOGLEERRORPRONE Same format as Google Error Prone.
PCLint PCLINT PC-Lint using the same output format as the Jenkins warnings plugin, details here
PHPCS CHECKSTYLE With phpcs api.php --report=checkstyle.
PHPPMD PMD With phpmd api.php xml ruleset.xml.
PMD PMD
Pep8 FLAKE8
PerlCritic PERLCRITIC
PiTest PITEST
ProtoLint PROTOLINT
Puppet-Lint CLANG With -log-format %{fullpath}:%{line}:%{column}: %{kind}: %{message}
PyDocStyle PYDOCSTYLE
PyFlakes FLAKE8
PyLint PYLINT With pylint --output-format=parseable.
ReSharper RESHARPER
RubyCop CLANG With rubycop -f clang file.rb
SARIF SARIF v2.x. Microsoft Visual C# can generate it with ErrorLog="BuildErrors.sarif,version=2".
SbtScalac SBTSCALAC
Scalastyle CHECKSTYLE
Semgrep SEMGREP With --json.
Simian SIMIAN
Sonar SONAR With mvn sonar:sonar -Dsonar.analysis.mode=preview -Dsonar.report.export.path=sonar-report.json. Removed in 7.7, see SONAR-11670 but can be retrieved with: curl --silent 'http://sonar-server/api/issues/search?componentKeys=unique-key&resolved=false' | jq -f sonar-report-builder.jq > sonar-report.json.
Spotbugs FINDBUGS
StyleCop STYLECOP
SwiftLint CHECKSTYLE With --reporter checkstyle.
TSLint CHECKSTYLE With -t checkstyle
Valgrind VALGRIND With --xml=yes.
XMLLint XMLLINT
XUnit XUNIT It only contains the failures.
YAMLLint YAMLLINT With -f parsable
ZPTLint ZPTLINT

52 parsers and 79 reporters.

Missing a format? Open an issue here!

The pull request will be commented like this.

Pull request comment

Available in Jenkins here.

Notify Jenkins from Bitbucket Server

  • You may trigger with a webhook in Bitbucket Server. And consume it with Generic Webhook Trigger plugin to get the variables you need.

  • Or, trigger with Pull Request Notifier for Bitbucket Server. It can supply any parameters and variables you may need. Here is an example URL. http://localhost:8080/jenkins/job/builder/buildWithParameters?FROM=${PULL_REQUEST_FROM_HASH}&TO=${PULL_REQUEST_TO_HASH}&TOSLUG=${PULL_REQUEST_TO_REPO_SLUG}&TOREPO=${PULL_REQUEST_TO_HTTP_CLONE_URL}&FROMREPO=${PULL_REQUEST_FROM_HTTP_CLONE_URL}&ID=${PULL_REQUEST_ID}&PROJECT=${PULL_REQUEST_TO_REPO_PROJECT_KEY}

Merge

You must perform the merge before build. If you don't perform the merge, the reported violations will refer to other lines then those in the pull request. The merge can be done with a shell script like this.

echo ---
echo --- Merging from $FROM in $FROMREPO to $TO in $TOREPO
echo ---
git clone $TOREPO
cd *
git reset --hard $TO
git status
git remote add from $FROMREPO
git fetch from
git merge $FROM
git --no-pager log --max-count=10 --graph --abbrev-commit

Your build command here!

Job DSL Plugin

This plugin can be used with the Job DSL Plugin. Here is an example.

I trigger it with Pull Request Notifier for Bitbucket Server with URL like http://jenkins:8080/job/Bitbucket_Server_PR_Builder/buildWithParameters?${EVERYTHING_URL}, I report back to Bitbucket Server with HTTP Request Plugin and Conditional BuildStep Plugin.

job('Bitbucket_Server_PR_Builder') {
 concurrentBuild()
 quietPeriod(0)
 parameters {
  stringParam('PULL_REQUEST_TO_HTTP_CLONE_URL', '')
  stringParam('PULL_REQUEST_TO_HASH', '')
  stringParam('PULL_REQUEST_FROM_HTTP_CLONE_URL', '')
  stringParam('PULL_REQUEST_FROM_HASH', '')
  stringParam('PULL_REQUEST_TO_REPO_PROJECT_KEY', '')
  stringParam('PULL_REQUEST_TO_REPO_SLUG', '')
  stringParam('PULL_REQUEST_ID','')
 }
 steps {
  httpRequest {
   url("http://admin:admin@bitbucket:7990/rest/api/1.0/projects/\$PULL_REQUEST_TO_REPO_PROJECT_KEY/repos/\$PULL_REQUEST_TO_REPO_SLUG/pull-requests/\$PULL_REQUEST_ID/comments")
   consoleLogResponseBody(true)
   httpMode("POST")
   acceptType('APPLICATION_JSON')
   contentType('APPLICATION_JSON')
   requestBody('{ "text": "Building... \$BUILD_URL" }')
  }

  shell('''
echo ---
echo --- Merging from $FROM in $FROMREPO to $TO in $TOREPO
echo ---
git clone $PULL_REQUEST_TO_HTTP_CLONE_URL
cd *
git reset --hard $PULL_REQUEST_TO_HASH
git status
git remote add from $PULL_REQUEST_FROM_HTTP_CLONE_URL
git fetch from
git merge $PULL_REQUEST_FROM_HASH
git --no-pager log --max-count=10 --graph --abbrev-commit

./gradlew build
  ''')

  conditionalBuilder {
   runCondition {
    statusCondition {
     worstResult('SUCCESS')
     bestResult('SUCCESS')
    }
    runner {
     runUnstable()
    }
    conditionalbuilders {
     httpRequest {
      url("http://admin:admin@bitbucket:7990/rest/api/1.0/projects/\$PULL_REQUEST_TO_REPO_PROJECT_KEY/repos/\$PULL_REQUEST_TO_REPO_SLUG/pull-requests/\$PULL_REQUEST_ID/comments")
      consoleLogResponseBody(true)
      httpMode("POST")
      acceptType('APPLICATION_JSON')
      contentType('APPLICATION_JSON')
      requestBody('{ "text": "Success... \$BUILD_URL" }')
     }
    }
   }
  }

  conditionalBuilder {
   runCondition {
    statusCondition {
     worstResult('FAILURE')
     bestResult('FAILURE')
    }
    runner {
     runUnstable()
    }
    conditionalbuilders {
     httpRequest {
      url("http://admin:admin@bitbucket:7990/rest/api/1.0/projects/\$PULL_REQUEST_TO_REPO_PROJECT_KEY/repos/\$PULL_REQUEST_TO_REPO_SLUG/pull-requests/\$PULL_REQUEST_ID/comments")
      consoleLogResponseBody(true)
      httpMode("POST")
      acceptType('APPLICATION_JSON')
      contentType('APPLICATION_JSON')
      requestBody('{ "text": "Failure... \$BUILD_URL" }')
     }
    }
   }
  }
 }
 publishers {
  violationsToBitbucketServerRecorder {
   config {
    bitbucketServerUrl("http://bitbucket:7990")
    projectKey("\$PULL_REQUEST_TO_REPO_PROJECT_KEY")
    repoSlug("\$PULL_REQUEST_TO_REPO_SLUG")
    pullRequestId("\$PULL_REQUEST_ID")

    credentialsId('bitbucketservercredentials')

    minSeverity('INFO')
    maxNumberOfViolations(99999)
    createSingleFileComments(true)
    createCommentWithAllSingleFileComments(false)
    commentOnlyChangedContent(true)
    commentOnlyChangedContentContext(5)
    commentOnlyChangedFiles(true)
    keepOldComments(false)
    
    commentTemplate("""
    **Reporter**: {{violation.reporter}}{{#violation.rule}}
    
    **Rule**: {{violation.rule}}{{/violation.rule}}
    **Severity**: {{violation.severity}}
    **File**: {{violation.file}} L{{violation.startLine}}{{#violation.source}}
    
    **Source**: {{violation.source}}{{/violation.source}}
    
    {{violation.message}}
    """)

    violationConfigs {
     violationConfig {
      parser("FINDBUGS")
      reporter("Findbugs")
      pattern(".*/findbugs/.*\\.xml\$")
     }
     violationConfig {
      parser("CHECKSTYLE")
      reporter("Checkstyle")
      pattern(".*/checkstyle/.*\\.xml\$")
     }
    }
   }
  }  
 }
}

Pipeline Plugin

This plugin can be used with the Pipeline Plugin:

node {
 deleteDir()
 
 stage('Merge') {
  sh '''
  git clone [email protected]:tomasbjerre/violations-test.git .
  git checkout master
  git merge origin/feature/addingcrap
  '''
 }

 stage('Build') {
  sh '''
  ./build.sh || ls
  '''
 }

 stage('Static code analysis') {
  ViolationsToBitbucketServer([
   bitbucketServerUrl: 'http://localhost:7990/',
   commentOnlyChangedContent: true,
   commentOnlyChangedContentContext: 5,
   commentOnlyChangedFiles: true,
   createCommentWithAllSingleFileComments: false,
   createSingleFileComments: true,
   maxNumberOfViolations: 99999,
   keepOldComments: true,
   projectKey: 'PROJ', // Use environment variable here
   pullRequestId: '1', // Use environment variable here
   repoSlug: 'violations-test', // Use environment variable here
   
   credentialsId: 'theid',
   
   commentTemplate: """
   **Reporter**: {{violation.reporter}}{{#violation.rule}}
   
   **Rule**: {{violation.rule}}{{/violation.rule}}
   **Severity**: {{violation.severity}}
   **File**: {{violation.file}} L{{violation.startLine}}{{#violation.source}}
   
   **Source**: {{violation.source}}{{/violation.source}}
   
   {{violation.message}}
   """,
   
   ignorePaths: [
       [path: 'node_modules'],
       [path: '.yarn']
   ],

   violationConfigs: [
    // Many more formats available, check https://github.com/tomasbjerre/violations-lib
    [parser: 'FINDBUGS', pattern: '.*/findbugs/.*\\.xml\$', reporter: 'Findbugs'],
    [parser: 'CHECKSTYLE', pattern: '.*/checkstyle/.*\\.xml\$', reporter: 'Checkstyle']
   ]
  ])
 }
}

Developer instructions

Instructions for developers.

Plugin development

More details on Jenkins plugin development is available here.

There is a /build.sh that will perform a full build and test the plugin.

If you have release-permissions this is how you do a release:

mvn release:prepare release:perform

violation-comments-to-stash-plugin's People

Contributors

daniel-beck-bot avatar jetersen avatar sghill avatar sghill-rewrite avatar szpak avatar timja avatar tomasbjerre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

violation-comments-to-stash-plugin's Issues

Plugin causes job hangs

I have a job that generates lint-compatible xml and violation comments plugin reports those violations to Bitbucket. Sometimes job hangs on "Report violations steps". Console output stops at

Archiving artifacts
---
--- Jenkins Violation Comments to Bitbucket Server ---
---
bitbucketServerUrl: https://bitbucket.example.com
projectKey: OI
repoSlug: reponame
pullRequestId: 2079
usernamePasswordCredentialsId: true
username: false
password: false
createSingleFileComments: true
createCommentWithAllSingleFileComments: false
commentOnlyChangedContent: false
commentOnlyChangedContentContext: 0
minSeverity: INFO
keepOldComments: false
LINT with pattern .*\\report.xml
Using username and password from credentials
Pull request: 2079
Workspace: F:\jenkins\jobs\SelfServiceHostConfigValidator\workspace
Found 21 violations from ViolationConfig [pattern=.*\\report.xml, reporter=LINT, parser=LINT].
PR: TPP/reponame/2079 on https://bitbucket.example.com

Environment:
Windows Server 2012 R2
Java: 1.8.0.151
I've spotted such behavior on Jenkins 2.73.3, 2.89.2
Plugin version: 1.63-1.65
I've just updated to 1.66 but I'm not sure, if this will help.
Thread dump: here

If you need any further information feel free to ask me.

Plugin aborts if it fails to delete a message

It seems the plugin aborts if it fails to delete a comment it created on a previous build. Unfortunately, comments that have been used as anchor for tasks are not deletable, so I get this:

[StaticAnalysisCheck] Error calling:
[StaticAnalysisCheck] https://git.richrelevance.com/rest/api/1.0/projects/RR/repos/root/pull-requests/257/comments/95485?version=0
[StaticAnalysisCheck] DELETE
[StaticAnalysisCheck] null

And then the plugin stops without doing anything else.

NPE since v1.76

We're getting a NPE since v1.76 (same with v1.77). We're using the global Bitbucket Base URL (Configure System -> Bitbucket Server Violations Server Defaults) and do not define it explicitly in our Pipeline script.

Publish results to Bitbucket server...
[Pipeline] ViolationsToBitbucketServer
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
[Bitbucket] Notifying pull request build result
[Bitbucket] Build result notified
java.lang.NullPointerException
	at java.net.URL.<init>(URL.java:532)
Caused: java.net.MalformedURLException
	at java.net.URL.<init>(URL.java:627)
	at java.net.URL.<init>(URL.java:490)
	at java.net.URL.<init>(URL.java:439)
	at org.jenkinsci.plugins.jvctb.ViolationsToBitbucketServerRecorder.createProxyConfigDetails(ViolationsToBitbucketServerRecorder.java:96)
	at org.jenkinsci.plugins.jvctb.ViolationsToBitbucketServerRecorder.perform(ViolationsToBitbucketServerRecorder.java:77)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:80)
	at org.jenkinsci.plugins.workflow.steps.CoreStep$Execution.run(CoreStep.java:67)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1$1.call(SynchronousNonBlockingStepExecution.java:50)
	at hudson.security.ACL.impersonate(ACL.java:290)
	at org.jenkinsci.plugins.workflow.steps.SynchronousNonBlockingStepExecution$1.run(SynchronousNonBlockingStepExecution.java:47)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)
Finished: FAILURE

[Help] java.io.IOException: Unable to serialize

Hello I get a exception when using your plugin with scalastyle (checkstyle):

java.io.IOException: remote file operation failed: /home/jenkins/workspace/envisia-erp-pr-builder at hudson.remoting.Channel@43d2f281:ci01.envisia.de: java.io.IOException: Unable to serialize

Which should actually not happen. Any ideas?

Parameter Documentation

I can figure out what most of the parameters are used for by their name but I'm confused about commentOnlyChangedContentContext, would you explain what this number means? I was also wondering if the comments can be restricted to only added changes. I'm seeing linting errors referring to deleted content, which I found distracting and unhelpful.

Support pylint output

Add support for reading pylint-format.

pylint --output-format=parseable --reports=n . > pylint.out

I tried configuring pylint.out file as FLAKE8 source file, but it produces something like:

************* Module fs.libcheck.libcheck
/home/musttu/Code/virtualenvs/cosmos/lib/python3.4/site-packages/fs/libcheck/libcheck.py:322: [C0330(bad-continuation), ] Wrong hanging indentation before block (add 4 spaces).
                    name == 'used_in_products' and self.presets.get('product') and
                    ^   |

Plugin output:

Dangling meta character '*' near index 0
*/pylint\.out
^

Pylint is also used by prospector. It allows reporting violations from various tools in pylint-format, so supporting pylint would tackle a bunch of tools. Prospector also supports other output formats (json, yaml, etc.), but I think those formats are less de-facto and supporting pylint would be the best bet.

Allow different reporter to use the same parser

Currently it is not possible to create different reporter with the same parser: only the last definition will be used:

violationConfigs: [
        [pattern: ".*/reports/lint-results-.*\\.xml\$", parser: 'ANDROIDLINT', reporter: "Lint ${flavor}"],
        [pattern: ".*/checkstyle/.*\\.xml\$", parser: 'CHECKSTYLE', reporter: "Checkstyle ${flavor}"],
        [pattern: '.*/findbugs/.*\\.xml\$', parser: 'FINDBUGS', reporter: "Findbugs ${flavor}"],
        [pattern: ".*/reports/ktlint-results-.*\\.xml\$", parser: 'CHECKSTYLE', reporter: "KtLint ${flavor}"],
]
Workspace: /opt/jenkins/workspace/Build_Android_Pull_Request@2
Found 275 violations from ViolationConfig [pattern=.*/reports/lint-results-.*\.xml$, reporter=Lint Italy, parser=ANDROIDLINT].
Found 3 violations from ViolationConfig [pattern=.*/reports/ktlint-results-.*\.xml$, reporter=KtLint Italy, parser=CHECKSTYLE].

In this example I have two different tools that both output their result in checkstyle format, KtLint and Checkstyle itself. It would be better to be able to set multiple reporter even if they use the same parser.

In alternative please add direct support for KtLint, but this will solve only temporarily the problem, until someone else need to use the same parser more than once.

File path on all comments in one message is absolute

This is the comment on a file:

Reporter: FINDBUGS
Rule: DMI_RANDOM_USED_ONLY_ONCE
Severity: WARN
File: com/rr/util/CheckStyleFindbugsCoverage.java L29
Source: com.rr.util.CheckStyleFindbugsCoverage

And this is the comment with all:

Reporter: CHECKSTYLE
Rule: com.puppycrawl.tools.checkstyle.checks.javadoc.JavadocParagraphCheck
Severity: WARN
File: /mnt/mesos/sandbox/jenkins/workspace/root_pipeline/common/util/src/main/java/com/rr/util/CheckStyleFindbugsCoverage.java L14

Maybe the difference is that one was generated by checkstyle and the other by findbugs? Either way, I'd really like to get rid of the absolute path if it's relative to the workspace. Given Paths file and the workspace directory at base, this does the trick: base.relativize(file), if it happens that it is checkstyle producing absolute paths, and not the style of comment.

Found 0 violations from ViolationConfig

I'm using your plugin in combination with the Bitbucket Branch Source Plugin (https://wiki.jenkins.io/display/JENKINS/Bitbucket+Branch+Source+Plugin) which performs the merge of the PR upon checkout:

 > C:\Program Files\Git\cmd\git.exe rev-parse --is-inside-work-tree # timeout=10
Fetching changes from 2 remote Git repositories
 > C:\Program Files\Git\cmd\git.exe config remote.origin.url ssh://[email protected]:1234/TEST/repo.git # timeout=10
Fetching without tags
Fetching upstream changes from ssh://[email protected]:1234/TEST/repo.git
 > C:\Program Files\Git\cmd\git.exe --version # timeout=10
using GIT_SSH to set credentials SSH key access on Bitbucket server
 > C:\Program Files\Git\cmd\git.exe fetch --no-tags --progress ssh://[email protected]:1234/TEST/repo.git +refs/pull-requests/27/from:refs/remotes/origin/PR-27
 > C:\Program Files\Git\cmd\git.exe config remote.upstream.url ssh://[email protected]:1234/TEST/repo.git # timeout=10
Fetching without tags
Fetching upstream changes from ssh://[email protected]:1234/TEST/repo.git
using GIT_SSH to set credentials SSH key access on Bitbucket server
 > C:\Program Files\Git\cmd\git.exe fetch --no-tags --progress ssh://[email protected]:1234/TEST/repo.git +refs/heads/master:refs/remotes/upstream/master
Merging remotes/upstream/master commit 2256767148ed57775c05af2b7a85d78a5388831f into PR head commit b600ebce173b62c7b68b6c080c5b07be4c039429
 > C:\Program Files\Git\cmd\git.exe config core.sparsecheckout # timeout=10
 > C:\Program Files\Git\cmd\git.exe checkout -f b600ebce173b62c7b68b6c080c5b07be4c039429
 > C:\Program Files\Git\cmd\git.exe merge 2256767148ed57775c05af2b7a85d78a5388831f # timeout=10
 > C:\Program Files\Git\cmd\git.exe rev-parse "HEAD^{commit}" # timeout=10
Merge succeeded, producing 864bbaa3e1ebd8d88d82b1a0d425f20949c40dc7
Checking out Revision 864bbaa3e1ebd8d88d82b1a0d425f20949c40dc7 (PR-27)
 > C:\Program Files\Git\cmd\git.exe config core.sparsecheckout # timeout=10
 > C:\Program Files\Git\cmd\git.exe checkout -f 864bbaa3e1ebd8d88d82b1a0d425f20949c40dc7
Commit message: "Merge commit '2256767148ed57775c05af2b7a85d78a5388831f' into HEAD"
 > C:\Program Files\Git\cmd\git.exe rev-list 0bd249813f3a6c3e5a16bbe10325ae3877ac68c3 # timeout=10

Afterwards I build the project and it produces the Checkstyle and Findbugs result files in target\checkstyle-result.xml and target\findbugsXml.xml. The PR contains a change which produces a new Findbugs warning which is also displayed in the findbugsXml.xml file as a BugInstance.

The plugin however does not seem to find any violations.

---
--- Jenkins Violation Comments to Bitbucket Server ---
---
bitbucketServerUrl: https://xyz.com
projectKey: TEST
repoSlug: repo
pullRequestId: 28
usernamePasswordCredentialsId: true
username: false
password: false
createSingleFileComments: true
createCommentWithAllSingleFileComments: false
commentOnlyChangedContent: false
commentOnlyChangedContentContext: 0
minSeverity: INFO
keepOldComments: false
Checkstyle with pattern .*/checkstyle-result\.xml$
Findbugs with pattern .*/findbugsXml\.xml$
Using username and password from credentials
Pull request: 28
Workspace: D:\app\BuildServer\jenkins-data\jobs\Repo\branches\PR-28\workspace
Found 0 violations from ViolationConfig [pattern=.*/checkstyle-result\.xml$, reporter=Checkstyle, parser=CHECKSTYLE].
Found 0 violations from ViolationConfig [pattern=.*/findbugsXml\.xml$, reporter=Findbugs, parser=FINDBUGS].
PR: TEST/repo/28 on https://xyz.com

Any idea what I'm doing wrong? Jenkins is running on Windows btw...

Credentials not found error

Jenkins 2.107 and violation-comments-to-stash-plugin 1.75
The plugin fails to report results from static analysis with following report.

15:26:22 bitbucketServerUrl: <URL>
15:26:22 projectKey: SDK
15:26:22 repoSlug: <REPO>
15:26:22 pullRequestId: 22
15:26:22 credentialsId: false
15:26:22 createSingleFileComments: true
15:26:22 createSingleFileCommentsTasks: false
15:26:22 createCommentWithAllSingleFileComments: true
15:26:22 commentOnlyChangedContent: false
15:26:22 commentOnlyChangedContentContext: 0
15:26:22 minSeverity: INFO
15:26:22 keepOldComments: false
15:26:22 commentTemplate: null
15:26:22 clang-tidy with pattern sa.log
15:26:22 Credentials not found!

I am running it from groovy pipeline script as follows:

withCredentials([usernameColonPassword(credentialsId: <ID>, variable: 'Credentials')]) {
  def credentials = env.Credentials
  ViolationsToBitbucketServer([
    bitbucketServerUrl: <URL>,
    createCommentWithAllSingleFileComments: true,
    createSingleFileComments: true,
    projectKey: to_project_key,
    repoSlug: to_project_slug,
    pullRequestId: pull_request_id,
    usernamePasswordCredentialsId: credentials, 
          
    violationConfigs: [
      [parser: 'CLANG', pattern: 'sa.log', reporter: 'clang-tidy'],
    ]
  ])
}

The plugin withCredentials is working - if I supply wrong ID it crashes even before it gets to ViolationsToBitbuckerServer part. I also tried the pipeline script on wiki with same result.

It seems like no matter what I write into usernamePasswordCredentialsId, credentialsId, username, password I always get message "Credentials not found!".

I think that this might be relevant: #14. But it did not help either.

Am I missing something? I was trying to setup this for past few days and I can't figure out what's wrong.
Thanks

Error when enabling the commentOnlyChangedContent option

We want a comment only on the changed content of the pull request (with context lines set to 10) and we're seeing this error when running the jenkins task :

com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Unterminated array at line 1 column 5882431 path $.diffs[132].fileComments[1]
 	at com.google.gson.Gson.fromJson(Gson.java:902)
 	at com.google.gson.Gson.fromJson(Gson.java:852)
 	at com.google.gson.Gson.fromJson(Gson.java:801)
 	at com.google.gson.Gson.fromJson(Gson.java:773)
 	at se.bjurr.violations.comments.bitbucketserver.lib.client.BitbucketServerClient.pullRequestDiff(BitbucketServerClient.java:91)
 	at se.bjurr.violations.comments.bitbucketserver.lib.BitbucketServerCommentsProvider$1.get(BitbucketServerCommentsProvider.java:36)
 	at se.bjurr.violations.comments.bitbucketserver.lib.BitbucketServerCommentsProvider$1.get(BitbucketServerCommentsProvider.java:33)
 	at com.google.common.base.Suppliers$ExpiringMemoizingSupplier.get(Suppliers.java:173)
 	at se.bjurr.violations.comments.bitbucketserver.lib.BitbucketServerCommentsProvider.shouldComment(BitbucketServerCommentsProvider.java:120)
 	at se.bjurr.violations.comments.lib.CommentsCreator.filterChanged(CommentsCreator.java:114)
 	at se.bjurr.violations.comments.lib.CommentsCreator.<init>(CommentsCreator.java:41)
 	at se.bjurr.violations.comments.lib.CommentsCreator.createComments(CommentsCreator.java:25)
 	at se.bjurr.violations.comments.bitbucketserver.lib.ViolationCommentsToBitbucketServerApi.toPullRequest(ViolationCommentsToBitbucketServerApi.java:113)
 	at org.jenkinsci.plugins.jvctb.perform.JvctbPerformer.doPerform(JvctbPerformer.java:95)
 	at org.jenkinsci.plugins.jvctb.perform.JvctbPerformer$1.invoke(JvctbPerformer.java:162)
 	at org.jenkinsci.plugins.jvctb.perform.JvctbPerformer$1.invoke(JvctbPerformer.java:149)
 	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2719)
 	at hudson.remoting.UserRequest.perform(UserRequest.java:118)
 	at hudson.remoting.UserRequest.perform(UserRequest.java:48)
 	at hudson.remoting.Request$2.run(Request.java:328)
 	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
 	at java.util.concurrent.FutureTask.run(Unknown Source)
 	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
 	at hudson.remoting.Engine$1$1.run(Engine.java:63)
 	at java.lang.Thread.run(Unknown Source)
 Caused by: com.google.gson.stream.MalformedJsonException: Unterminated array at line 1 column  path $.diffs[132].fileComments[1]
 	at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1559)
 	at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:476)
 	at com.google.gson.stream.JsonReader.skipValue(JsonReader.java:1224)
 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:218)
 	at com.google.gson.internal.bind.TypeAdapterRuntimeTypeWrapper.read(TypeAdapterRuntimeTypeWrapper.java:41)
 	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:82)
 	at com.google.gson.internal.bind.CollectionTypeAdapterFactory$Adapter.read(CollectionTypeAdapterFactory.java:61)
 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$1.read(ReflectiveTypeAdapterFactory.java:129)
 	at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory$Adapter.read(ReflectiveTypeAdapterFactory.java:220)
 	at com.google.gson.Gson.fromJson(Gson.java:887)
 	... 25 more

We are using the latest version of the plugin (1.36) with bitbucket server 4.3

Failure invoking plugin: GET changes returns null

I have server URL (+credentials), project and repo keys configured. When I run build, it fails to:


---
--- Jenkins Violation Comments to Bitbucket Server ---

---
bitbucketServerUrl: https://mystash.gtn
projectKey: COSMOS
repoSlug: cosmos
pullRequestId: 184
usernamePasswordCredentialsId: true
username: false
password: false
createSingleFileComments: false
createCommentWithAllSingleFileComments: false
ANDROIDLINT with pattern 
CHECKSTYLE with pattern 
CPPCHECK with pattern 
CPPLINT with pattern 
CSSLINT with pattern 
FINDBUGS with pattern 
FLAKE8 with pattern flake8.out
FXCOP with pattern 
JSHINT with pattern 
LINT with pattern 
PERLCRITIC with pattern 
PITEST with pattern 
PMD with pattern 
RESHARPER with pattern 
STYLECOP with pattern 
XMLLINT with pattern 
Using username and password from credentials
Will comment 184
Workspace: /home/jenkins/workspace/COSMOS-pullrequests
Found 0 violations from ViolationConfig [reporter=FLAKE8, pattern=flake8.out].
Will comment PR COSMOS/cosmos/184 on https://mystash.gtn
Error calling:
https://mystash.gtn/rest/api/1.0/projects/COSMOS/repos/cosmos/pull-requests/184/changes?limit=999999
GET
null

If I run that query from command line:

curl -u user:pass https://mystash.gtn/rest/api/1.0/projects/COSMOS/repos/cosmos/pull-requests/184/changes?limit=999999

{"fromHash":"9a4694b7fdf89163cd5caa880193f41273071c0d","toHash":"a78ee3de5f3c83bf79bb4c4057ca74174eff7e39","values":[{"contentId":"a77b0ec15f396e6ac61ee24a178324c79cc5bae9","fromContentId":"1136127a32ee434a1f5cae9a0a8a9f8ee96b9ce4","path":{"components":["tasks.py"],"parent":"","name":"tasks.py","extension":"py","toString":"tasks.py"},"executable":false,"percentUnchanged":-1,"type":"MODIFY","nodeType":"FILE","srcExecutable":false,"links":{"self":[null]}}],"size":1,"isLastPage":true,"start":0,"limit":999999,"nextPageStart":null}

Any pointers what might be wrong here? Bitbucket Server version is 4.9.1 and in the PR I'm building I have changes in tasks.py.

At least the error message should be improved (if I'm just missing configs).

Individual comments and keeping previous comments

Hi, I was wondering if there is a way to always have individual comments, even if there are multiple comments on the same file or even row.

I tried to set createCommentWithAllSingleFileComments and createSingleFileComments both to false but than I got no comments at all.

Also I would like to know if is possible to keep the previous comments when I trigger a build a second time. I'm asking because my current pipeline build multiple flavors of the same Android App using multiple parallel jobs and every single job calls the ViolationsToBitbucketServerRecorder but it seems that every time is called, for the same PR, it removes the previous report comments.

Plugin doesnโ€™t send comments to bitbucket

I can't realize why it doesn't publish comments into bitbucket.

Here is a part of pipeline:

ViolationsToBitbucketServer([bitbucketServerUrl: 'https://bitbucket.astrazeneca.net', 
                                               commentTemplate: '''**Reporter**: {{violation.reporter}}{{#violation.rule}}

                                               **Rule**: {{violation.rule}}{{/violation.rule}}
                                               **Severity**: {{violation.severity}}
                                               **File**: {{violation.file}} L{{violation.startLine}}{{#violation.source}}

                                               **Source**: {{violation.source}}{{/violation.source}}

                                               {{violation.message}}''', 
                                               createCommentWithAllSingleFileComments: true, 
                                               credentialsId: '80981402-7ed6-490d-96ee-1a7dcaab9921',
                                               keepOldComments: true, minSeverity: 'WARN', 
                                               projectKey: 'SCP', 
                                               pullRequestId: "$params.pullrequest", 
                                               repoSlug: 'scpcore', 
                                               violationConfigs: [[parser: 'YAMLLINT', pattern: '.*lint_result*\\.txt$', reporter: 'yamllint']]
                                               ])

And here what I see in jenkins console:

2018-09-17 16:13:25 ---
2018-09-17 16:13:25 --- Jenkins Violation Comments to Bitbucket Server ---
2018-09-17 16:13:25 ---
2018-09-17 16:13:25 bitbucketServerUrl: https://bitbucket.astrazeneca.net
2018-09-17 16:13:25 projectKey: SCP
2018-09-17 16:13:25 repoSlug: scpcore
2018-09-17 16:13:25 pullRequestId: 967
2018-09-17 16:13:25 credentialsId: true
2018-09-17 16:13:25 createSingleFileComments: false
2018-09-17 16:13:25 createSingleFileCommentsTasks: false
2018-09-17 16:13:25 createCommentWithAllSingleFileComments: true
2018-09-17 16:13:25 commentOnlyChangedContent: false
2018-09-17 16:13:25 commentOnlyChangedContentContext: 0
2018-09-17 16:13:25 minSeverity: WARN
2018-09-17 16:13:25 keepOldComments: true
2018-09-17 16:13:25 commentTemplate: **Reporter**: {{violation.reporter}}{{#violation.rule}}
2018-09-17 16:13:25                                                 
2018-09-17 16:13:25                                                 **Rule**: {{violation.rule}}{{/violation.rule}}
2018-09-17 16:13:25                                                 **Severity**: {{violation.severity}}
2018-09-17 16:13:25                                                 **File**: {{violation.file}} L{{violation.startLine}}{{#violation.source}}
2018-09-17 16:13:25                                                 
2018-09-17 16:13:25                                                 **Source**: {{violation.source}}{{/violation.source}}
2018-09-17 16:13:25                                                 
2018-09-17 16:13:25                                                 {{violation.message}}
2018-09-17 16:13:25 yamllint with pattern .*lint_result*\.txt$
2018-09-17 16:13:25 Pull request: 967
2018-09-17 16:13:25 Workspace: /home/easybuild-jenkins/workspace/Development/aleksei_test/ansible_lint/scpcore
2018-09-17 16:13:25 Found 13 violations from ViolationConfig [pattern=.*lint_result*\.txt$, reporter=yamllint, parser=YAMLLINT].
2018-09-17 16:13:25 PR: SCP/scpcore/967 on https://bitbucket.astrazeneca.net

Jenkins log is empty, no errors during a build.

What I do wrong?

Best regards,
Aleksei Philippov

Hello Tomas,

Could you please help me with this plugin. I can't realize why it doesn't publish comments into bitbucket.

Here is a part of pipeline:

ViolationsToBitbucketServer([bitbucketServerUrl: 'https://bitbucket.astrazeneca.net', 
                                               commentTemplate: '''**Reporter**: {{violation.reporter}}{{#violation.rule}}

                                               **Rule**: {{violation.rule}}{{/violation.rule}}
                                               **Severity**: {{violation.severity}}
                                               **File**: {{violation.file}} L{{violation.startLine}}{{#violation.source}}

                                               **Source**: {{violation.source}}{{/violation.source}}

                                               {{violation.message}}''', 
                                               createCommentWithAllSingleFileComments: true, 
                                               credentialsId: '80981402-7ed6-490d-96ee-1a7dcaab9921',
                                               keepOldComments: true, minSeverity: 'WARN', 
                                               projectKey: 'SCP', 
                                               pullRequestId: "$params.pullrequest", 
                                               repoSlug: 'scpcore', 
                                               violationConfigs: [[parser: 'YAMLLINT', pattern: '.*lint_result*\\.txt$', reporter: 'yamllint']]
                                               ])

And here what I see in jenkins console:

2018-09-17 16:13:25 ---
2018-09-17 16:13:25 --- Jenkins Violation Comments to Bitbucket Server ---
2018-09-17 16:13:25 ---
2018-09-17 16:13:25 bitbucketServerUrl: https://bitbucket.astrazeneca.net
2018-09-17 16:13:25 projectKey: SCP
2018-09-17 16:13:25 repoSlug: scpcore
2018-09-17 16:13:25 pullRequestId: 967
2018-09-17 16:13:25 credentialsId: true
2018-09-17 16:13:25 createSingleFileComments: false
2018-09-17 16:13:25 createSingleFileCommentsTasks: false
2018-09-17 16:13:25 createCommentWithAllSingleFileComments: true
2018-09-17 16:13:25 commentOnlyChangedContent: false
2018-09-17 16:13:25 commentOnlyChangedContentContext: 0
2018-09-17 16:13:25 minSeverity: WARN
2018-09-17 16:13:25 keepOldComments: true
2018-09-17 16:13:25 commentTemplate: **Reporter**: {{violation.reporter}}{{#violation.rule}}
2018-09-17 16:13:25                                                 
2018-09-17 16:13:25                                                 **Rule**: {{violation.rule}}{{/violation.rule}}
2018-09-17 16:13:25                                                 **Severity**: {{violation.severity}}
2018-09-17 16:13:25                                                 **File**: {{violation.file}} L{{violation.startLine}}{{#violation.source}}
2018-09-17 16:13:25                                                 
2018-09-17 16:13:25                                                 **Source**: {{violation.source}}{{/violation.source}}
2018-09-17 16:13:25                                                 
2018-09-17 16:13:25                                                 {{violation.message}}
2018-09-17 16:13:25 yamllint with pattern .*lint_result*\.txt$
2018-09-17 16:13:25 Pull request: 967
2018-09-17 16:13:25 Workspace: /home/easybuild-jenkins/workspace/Development/aleksei_test/ansible_lint/scpcore
2018-09-17 16:13:25 Found 13 violations from ViolationConfig [pattern=.*lint_result*\.txt$, reporter=yamllint, parser=YAMLLINT].
2018-09-17 16:13:25 PR: SCP/scpcore/967 on https://bitbucket.astrazeneca.net

Jenkins log is empty, no errors during a build.

What I do wrong?

No PR comments for Finbugs

I have configured the plugin for Checkstyle and Findbugs violations but only Checkstyle comments are visible in the PR. Do you have any suggestions how I can investigate the reason of having no comments for Findbugs? Last part of my Jenkins PR builder job log is:

---
--- Jenkins Violation Comments to Bitbucket Server ---
---
bitbucketServerUrl: [REDACTED]
projectKey: BEST
repoSlug: [REDACTED]
pullRequestId: 201
usernamePasswordCredentialsId: true
username: false
password: false
createSingleFileComments: true
createCommentWithAllSingleFileComments: false
commentOnlyChangedContent: false
commentOnlyChangedContentContext: 0
ANDROIDLINT with pattern 
CHECKSTYLE with pattern .*/checkstyle-result\.xml$
CODENARC with pattern 
CPD with pattern 
CPPCHECK with pattern 
CPPLINT with pattern 
CSSLINT with pattern 
FINDBUGS with pattern .*/findbugsXml\.xml$
FLAKE8 with pattern 
FXCOP with pattern 
GENDARME with pattern 
JCREPORT with pattern 
JSHINT with pattern 
LINT with pattern 
MYPY with pattern 
PERLCRITIC with pattern 
PITEST with pattern 
PMD with pattern 
PYDOCSTYLE with pattern 
PYLINT with pattern 
RESHARPER with pattern 
SIMIAN with pattern 
STYLECOP with pattern 
XMLLINT with pattern 
ZPTLINT with pattern 
Using username and password from credentials
Will comment 201
Workspace: /var/jenkins_home/jobs/[REDACTED]-pull-request-builder/workspace
Found 3 violations from ViolationConfig [reporter=CHECKSTYLE, pattern=.*/checkstyle-result\.xml$].
Found 25 violations from ViolationConfig [reporter=FINDBUGS, pattern=.*/findbugsXml\.xml$].
Will comment PR BEST/[REDACTED]/201 on [REDACTED]
Notified Stash for commit with id c0d13ffe5273c2a3bdd5e7e06258f0f1466b0a1c
Finished: SUCCESS

I'm using the latest version of the plugin (1.43)

Violation plugin iterates over files not mentioned in report

Violation plugin scans all files in pull request and tries to get information about them even if ther are not mentioned in report file:

2019-02-12_16h04_46

Here's my plugin configuration:

2019-02-12_16h00_31

This behavior slows down build process because build is not finished until all files are processed.

Even after I changed commentOnlyChangedContent to true, nothing changed and plugin keeps iteration over all files in pull request.

Info

  • Plugin version: 1.97
  • Jenkins version: 2.150.2

Allow INFO Files changed to include all scanned files

Currently the plugin reads the various violation files and parses the output. However, if the file includes four scanned files it will only feed back the two that were changed in the pull request (example below). This is becoming an issue for me as we use ansible-lint which will scan dependencies/imported files. There is no setting to disable it there either and I'm not opposed to the files being scanned, more that the output is being suppressed by this plugin and not being fed back like the rest.

I realize there would be no file to associate the comments with and it would have to be a Pull Request level comment.

combine credentials

instead of having two credentials fields you could combine them and just on the plugin side choose what to do with it depending on the resolved credential type.

Escaped single quote characters in comments

XML report example:

image

Bitbucket comment:

image

XML report is being produced by a custom tool, not by generic Lint but the format is lint-compatible. I've checked the report against XML validator and it seems to be totally valid.


Jenkins version: 2.138.1
Plugin version: 1.90

Password in clear text

The way you use credentials plugin is bad, you should never put the password in clear text, which you do several times through logging and in config xml ๐Ÿ™ˆ ๐Ÿ™‰ ๐Ÿ™Š
Working on a PR that fixes a lot of your jelly hacking and going to deprecate the use of username and password.

Problem with Pipeline Snippet Generation

I tried to generate a snippet for the linked configuration, and got this:

step <object of type org.jenkinsci.plugins.jvctb.ViolationsToBitbucketServerRecorder>

A screenshot of the configuration here.

Re-using credentials from System config causes java.lang.NullPointerException: username not set!

In Manage Jenkins > Configure System:

image

In job config:

image

I haven't check either username/password combination, because I want to re-use credentials defined in system config.

This causes following trace:


---
--- Jenkins Violation Comments to Bitbucket Server ---

---
bitbucketServerUrl: https://mystash.gtn
projectKey: COSMOS
repoSlug: cosmos
pullRequestId: 184
usernamePasswordCredentialsId: true
username: false
password: false
createSingleFileComments: false
createCommentWithAllSingleFileComments: false
ANDROIDLINT with pattern 
CHECKSTYLE with pattern 
CPPCHECK with pattern 
CPPLINT with pattern 
CSSLINT with pattern 
FINDBUGS with pattern 
FLAKE8 with pattern 
FXCOP with pattern 
JSHINT with pattern 
LINT with pattern 
PERLCRITIC with pattern 
PITEST with pattern 
PMD with pattern 
PYLINT with pattern .*/pylint\.out
RESHARPER with pattern 
STYLECOP with pattern 
XMLLINT with pattern 
Will comment 184
Workspace: /home/jenkins/workspace/COSMOS-musttutest
Found 0 violations from ViolationConfig [reporter=PYLINT, pattern=.*/pylint\.out].
java.lang.NullPointerException: username not set!
    at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:204)
    at org.jenkinsci.plugins.jvctb.perform.JvctbPerformer.doPerform(JvctbPerformer.java:74)
    at org.jenkinsci.plugins.jvctb.perform.JvctbPerformer$1.invoke(JvctbPerformer.java:155)
    at org.jenkinsci.plugins.jvctb.perform.JvctbPerformer$1.invoke(JvctbPerformer.java:142)
    at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2772)
    at hudson.remoting.UserRequest.perform(UserRequest.java:153)
    at hudson.remoting.UserRequest.perform(UserRequest.java:50)
    at hudson.remoting.Request$2.run(Request.java:332)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
    at ......remote call to flexible-docker-02(Native Method)
    at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1416)
    at hudson.remoting.UserResponse.retrieve(UserRequest.java:253)
    at hudson.remoting.Channel.call(Channel.java:781)
    at hudson.FilePath.act(FilePath.java:1007)
    at hudson.FilePath.act(FilePath.java:996)
    at org.jenkinsci.plugins.jvctb.perform.JvctbPerformer.jvctsPerform(JvctbPerformer.java:142)
    at org.jenkinsci.plugins.jvctb.ViolationsToBitbucketServerRecorder.perform(ViolationsToBitbucketServerRecorder.java:61)
    at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:78)
    at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
    at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:779)
    at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:720)
    at hudson.model.Build$BuildExecution.post2(Build.java:185)
    at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:665)
    at hudson.model.Run.execute(Run.java:1766)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
    at hudson.model.ResourceController.execute(ResourceController.java:98)
    at hudson.model.Executor.run(Executor.java:410)

What's interesting is that this doesn't actually fail the build, it continues:

Started calculate disk usage of build
Finished Calculation of disk usage of build in 0 seconds
Started calculate disk usage of workspace
Finished Calculation of disk usage of workspace in 0 seconds
Finished: SUCCESS

Adding credentials in job config resolves the problem.

Running 1.30 version. Not sure, but I think it worked in 1.27.

How to investigate comment failure?

I can see that plugin wants to leave comment, but I never see comment show up on BitBucket. How do I investigate? I do not have access to BitBucket hosts, but I do have access to Jenkins host.

Output from plugin

bitbucketServerUrl: https://bitbucketdc.xxxxx.net
projectKey: APP1
repoSlug: repo-slug
pullRequestId: 430
usernamePasswordCredentialsId: true
username: false
password: false
createSingleFileComments: true
createCommentWithAllSingleFileComments: false
commentOnlyChangedContent: false
commentOnlyChangedContentContext: 2
ANDROIDLINT with pattern 
CHECKSTYLE with pattern .*/target/checkstyle/.*\.xml$
CODENARC with pattern 
CLANG with pattern 
CPD with pattern 
CPPCHECK with pattern 
CPPLINT with pattern 
CSSLINT with pattern 
FINDBUGS with pattern .*/target/findbugs/.*\.xml$
FLAKE8 with pattern 
FXCOP with pattern 
GENDARME with pattern 
JCREPORT with pattern 
JSHINT with pattern 
LINT with pattern 
MYPY with pattern 
GOLINT with pattern 
PERLCRITIC with pattern 
PITEST with pattern 
PMD with pattern pmd.xml
PYDOCSTYLE with pattern 
PYLINT with pattern 
RESHARPER with pattern 
SIMIAN with pattern 
STYLECOP with pattern 
XMLLINT with pattern 
ZPTLINT with pattern 
Using username and password from credentials
Will comment 430
Workspace: /path/to/workspace/JenkinsJobName
Found 4 violations from ViolationConfig [reporter=CHECKSTYLE, pattern=.*/target/checkstyle/.*\.xml$].
Found 111 violations from ViolationConfig [reporter=FINDBUGS, pattern=.*/target/findbugs/.*\.xml$].
Found 0 violations from ViolationConfig [reporter=PMD, pattern=pmd.xml].
Will comment PR APP1/repo-slug/430 on https://bitbucketdc.xxxx.net
Notified Stash for commit with id 60cc695dc36278713e1069d8fb17a7589d560874
Notifying upstream projects of job completion

Recognition of changed lines seems to not work correclty

Hi,

it seems that changed/unchanged files are recognized correctly, but changed/unchanged lines not. In the following there is an example. Line 39 of ListView.cpp changed. In this change many files have been renamed/moved. In Bitbucket Diff-View files are shown as deleted and added, but in git history, files are shown as renamed. However ListView.cpp was only modified.

Actually, for this PR not 1 comment has been created on Bitbucket. I have retested another PR, there warnings have been recreated (after deleting them before re-execution). I encountered the problem with plug-in version 1.80. I updated to 1.89, but same problem.

unrecognized warning

Compiler output, where the path is changed by script afterwards.

../../source/gui/controls/ListView.cpp:39:61: warning: default argument given for parameter 2 of 'pfm::ListView::ListView(const PegRect&, PEGUINT)' [-fpermissive]

Actually, the specific line is changed, but warning is not reported. In the plugin output you can see, that +-10 lines around changed lines should be reported:

Using proxy: 127.0.0.1:3128
---
--- Jenkins Violation Comments to Bitbucket Server ---
---
bitbucketServerUrl: <server-url>
projectKey: P2
repoSlug: code
pullRequestId: 48
credentialsId: true
createSingleFileComments: true
createSingleFileCommentsTasks: false
createCommentWithAllSingleFileComments: false
commentOnlyChangedContent: true
commentOnlyChangedContentContext: 10
minSeverity: INFO
keepOldComments: false
commentTemplate: 
CPPCHECK with pattern .*DeduplicatedCppcheckResult\.txt$
 with pattern .*cpplintResult\.xml$
GCC with pattern .*DeduplicatedGccOutput\.txt$
DOXYGEN with pattern .*DoxygenOutput\.txt$
Pull request: 48
Workspace: /srv/www/jenkins/workspace/code_PR-48-KGAD5IYWWUHLZ57VV6B6ZBCWRPMR3YBWCP6PDMVT4TV3MZE2KESQ
Found 131 violations from ViolationConfig [pattern=.*DeduplicatedCppcheckResult\.txt$, reporter=CPPCHECK, parser=CLANG].
Found 1089 violations from ViolationConfig [pattern=.*cpplintResult\.xml$, reporter=, parser=CPPLINT].
Found 200 violations from ViolationConfig [pattern=.*DeduplicatedGccOutput\.txt$, reporter=GCC, parser=CLANG].
Found 73 violations from ViolationConfig [pattern=.*DoxygenOutput\.txt$, reporter=DOXYGEN, parser=CLANG].
PR: P2/code/48 on <server-url>
INFO GET <server-url>rest/api/1.0/projects/P2/repos/code/pull-requests/48/changes?limit=999999 200 
INFO Files changed:
  pump/source/gui/controls/ListView.cpp
  // many other files
INFO Files with violations:
  * // this looks strange
  pump/source/gui/controls/ListView.cpp
  // many other files
INFO GET <server-url>rest/api/1.0/projects/P2/repos/code/pull-requests/48/diff?limit=999999 200 
INFO Will not include violations on changed files because violation reported on untouched lines:
  pump/source/gui/controls/ListView.cpp 18
  pump/source/gui/controls/ListView.cpp 19
  pump/source/gui/controls/ListView.cpp 199
  pump/source/gui/controls/ListView.cpp 20
  pump/source/gui/controls/ListView.cpp 21
  pump/source/gui/controls/ListView.cpp 215
  pump/source/gui/controls/ListView.cpp 22
  pump/source/gui/controls/ListView.cpp 220
  pump/source/gui/controls/ListView.cpp 27
  pump/source/gui/controls/ListView.cpp 28
  pump/source/gui/controls/ListView.cpp 281
  pump/source/gui/controls/ListView.cpp 29
  pump/source/gui/controls/ListView.cpp 30
  pump/source/gui/controls/ListView.cpp 39 // <---------------------- why untouched?
  // many other findings listed
INFO Will not include violations on unchanged files:
  * 0  // I don't know what this should mean, file names *? May this cause problems?
  /pump/external/specific/arm/cmsis/arm_math.h 2212
  // several other files, chosen files look correct
  tests/src/util/FlaggedTypeTests.cpp 268
INFO GET <server-url>rest/api/1.0/projects/P2/repos/code/pull-requests/48/changes?limit=999999 200 
INFO GET <server-url>rest/api/1.0/projects/P2/repos/code/pull-requests/48/comments?path=pump%2Fbuild%2FMakefile.common.gcc.mk&limit=999999 200 
INFO Found no comments from <server-url>rest/api/1.0/projects/P2/repos/code/pull-requests/48/comments?path=pump%2Fbuild%2FMakefile.common.gcc.mk&limit=999999 with JSONPath $.values[*] in JSON:
{"size":0,"limit":999999,"isLastPage":true,"values":[],"start":0}

// many more requests with same results but different paths

INFO Asking BitbucketServerCommentsProvider to comment:
// ends here, no comments in Bitbucket

java.lang.NullPointerException from violations-lib

Hi Tomas, the plugin has been running silk smooth but I now encountered a problem:

11:40:38 ---
11:40:38 --- Jenkins Violation Comments to Bitbucket Server ---
11:40:38 ---
11:40:38 bitbucketServerUrl: https://stash.XXXXX.com
11:40:38 projectKey: COSMOS
11:40:38 repoSlug: cosmos
11:40:38 pullRequestId: 330
11:40:38 usernamePasswordCredentialsId: true
11:40:38 username: false
11:40:38 password: false
11:40:38 createSingleFileComments: true
11:40:38 createCommentWithAllSingleFileComments: false
11:40:38 commentOnlyChangedContent: true
11:40:38 commentOnlyChangedContentContext: 5
11:40:38 minSeverity: INFO
11:40:38 ANDROIDLINT with pattern null
11:40:38 CHECKSTYLE with pattern null
11:40:38 CODENARC with pattern null
11:40:38 CLANG with pattern null
11:40:38 CPD with pattern null
11:40:38 CPPCHECK with pattern null
11:40:38 CPPLINT with pattern null
11:40:38 CSSLINT with pattern null
11:40:38 FINDBUGS with pattern null
11:40:38 FLAKE8 with pattern cosmos/.*/pycodestyle\.out$
11:40:38 FXCOP with pattern null
11:40:38 GENDARME with pattern null
11:40:38 JCREPORT with pattern null
11:40:38 JSHINT with pattern null
11:40:38 LINT with pattern null
11:40:38 KLOCWORK with pattern null
11:40:38 MYPY with pattern cosmos/.*/mypy\.out$
11:40:38 GOLINT with pattern null
11:40:38 PERLCRITIC with pattern null
11:40:38 PITEST with pattern null
11:40:38 PMD with pattern null
11:40:38 PYDOCSTYLE with pattern cosmos/.*/pydocstyle\.out$
11:40:38 PYLINT with pattern cosmos/.*/pylint\.out$
11:40:38 RESHARPER with pattern null
11:40:38 SBTSCALAC with pattern null
11:40:38 SIMIAN with pattern null
11:40:38 STYLECOP with pattern null
11:40:38 XMLLINT with pattern null
11:40:38 ZPTLINT with pattern null
11:40:38 Using username and password from credentials
11:40:38 Will comment 330
11:40:38 Workspace: /home/jenkins/workspace/COSMOS-pullrequests
11:40:38 java.lang.NullPointerException
11:40:38 	at se.bjurr.violations.lib.ViolationsReporterApi.violations(ViolationsReporterApi.java:55)
11:40:38 	at org.jenkinsci.plugins.jvctb.perform.JvctbPerformer.doPerform(JvctbPerformer.java:82)
11:40:38 	at org.jenkinsci.plugins.jvctb.perform.JvctbPerformer$1.invoke(JvctbPerformer.java:195)
11:40:38 	at org.jenkinsci.plugins.jvctb.perform.JvctbPerformer$1.invoke(JvctbPerformer.java:183)
11:40:38 	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2749)
11:40:38 	at hudson.remoting.UserRequest.perform(UserRequest.java:153)
11:40:38 	at hudson.remoting.UserRequest.perform(UserRequest.java:50)
11:40:38 	at hudson.remoting.Request$2.run(Request.java:336)
11:40:38 	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
11:40:38 	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
11:40:38 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
11:40:38 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
11:40:38 	at java.lang.Thread.run(Thread.java:748)
11:40:38 	at ......remote call to flexible-docker-04(Native Method)
11:40:38 	at hudson.remoting.Channel.attachCallSiteStackTrace(Channel.java:1545)
11:40:38 	at hudson.remoting.UserResponse.retrieve(UserRequest.java:253)
11:40:38 	at hudson.remoting.Channel.call(Channel.java:830)
11:40:38 	at hudson.FilePath.act(FilePath.java:987)
11:40:38 	at hudson.FilePath.act(FilePath.java:976)
11:40:38 	at org.jenkinsci.plugins.jvctb.perform.JvctbPerformer.jvctsPerform(JvctbPerformer.java:182)
11:40:38 	at org.jenkinsci.plugins.jvctb.ViolationsToBitbucketServerRecorder.perform(ViolationsToBitbucketServerRecorder.java:68)
11:40:38 	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:81)
11:40:38 	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
11:40:38 	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:735)
11:40:38 	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:676)
11:40:38 	at hudson.model.Build$BuildExecution.post2(Build.java:186)
11:40:38 	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:621)
11:40:38 	at hudson.model.Run.execute(Run.java:1760)
11:40:38 	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
11:40:38 	at hudson.model.ResourceController.execute(ResourceController.java:97)
11:40:38 	at hudson.model.Executor.run(Executor.java:405)

This may be related to a recent Jenkins upgrade but I'm not sure. I'm running:

  • Jenkins 2.60.2
  • violation-comments-to-stash-plugin 1.52 (the latest in update center). I was running 1.51 earlier, but upgrading didn't change anything.

The error points to https://github.com/tomasbjerre/violations-lib/blob/master/src/main/java/se/bjurr/violations/lib/ViolationsReporterApi.java#L55 but the bundled file is probably of different revision...

Error messages should be escaped

Publishing comments failed, because plugin doesn't escape error message content and Stash attempts to interpret \ prefixed characters . For example, comment:

Found 1 violation:
Reporter: PYLINT
Rule: anomalous-backslash-in-string
Severity: WARN
File: fs/csm/admin_api/admin_api.py L1086

Anomalous backslash in string: '\s'. String constant might be missing an r prefix.
<this is a auto generated comment from violation-comments-lib F7F8ASD8123FSDF>

Gets POSTed as:

$ curl -u user:pass -X POST -H 'Content-Type: application/json' -d "{\"text\": \"Found 1 violation:\n\nReporter: PYLINT\nRule: anomalous-backslash-in-string\nSeverity: WARN\nFile: fs/csm/admin_api/auth.py L52\n \n\nAnomalous backslash in string: '\.'. String constant might be missing an r prefix.\n\n<this is a auto generated comment from violation-comments-lib F7F8ASD8123FSDF>\"}" https://mystash.gtn/rest/api/1.0/projects/COSMOS/repos/cosmos/pull-requests/185/comments

{"errors":[{"context":null,"message":"Unrecognized character escape 's' (code 115)\n at [Source: com.atlassian.stash.internal.web.util.web.CountingServletInputStream@31131921; line: 1, column: 186]","exceptionName":"org.codehaus.jackson.JsonParseException"}]}root@a53ac6de14b0:/# 

Adding double escaping (from shell) works:

$ curl -u user:pass -X POST -H 'Content-Type: application/json' -d "{\"text\": \"Found 1 violation:\n\nReporter: PYLINT\nRule: anomalous-backslash-in-string\nSesm/admin_api/admin_api.py L1086\n \n\nAnomalous backslash in string: '\\\s'. String constant might be missing an r prefix.\n\n<this is a auto generated comment from violation-comments-lib F7F8ASD8123FSDF>\"}" https://mystash.gtn/rest/api/1.0/projects/COSMOS/repos/cosmos/pull-requests/185/comments

{"properties":{"repositoryId":713},"id":121713,"version":0,"text":"Found 1 violation:\n\nReporter: PYLINT\nRule: anomalous-backslash-in-string\nSeverity: WARN\nFile: fs/csm/admin_api/admin_api.py L1086\n \n\nAnomalous backslash in string: '\\s'. String constant might be missing an r prefix.\n\n<this is a auto generated comment from violation-comments-lib F7F8ASD8123FSDF>","author":{"name":"rd-team-essentials-s","emailAddress":"","id":4763,"displayName":"rd-team-essentials-s","active":true,"slug":"rd-team-essentials-s","type":"NORMAL","links":{"self":[{"href":"https://mystash.gtn/users/rd-team-essentials-s"}]}},"createdDate":1477403666741,"updatedDate":1477403666741,"comments":[],"tasks":[],"permittedOperations":{"editable":true,"deletable":true}}

CredentialsId not working

Jenkins 2.17, Viiolation-comments-to-stash-plugin 1.21.

The plugin fail to report to Bitbucket if using the CredentialsId. This is what I get in the log:

[CheckstyleCheck] ---
[CheckstyleCheck] --- Jenkins Violation Comments to Bitbucket Server ---
[CheckstyleCheck] ---
[CheckstyleCheck] bitbucketServerUrl: https://git.richrelevance.com
[CheckstyleCheck] projectKey: RR
[CheckstyleCheck] repoSlug: root
[CheckstyleCheck] pullRequestId: 257
[CheckstyleCheck] usernamePasswordCredentialsId: true
[CheckstyleCheck] username: false
[CheckstyleCheck] password: false
[CheckstyleCheck] createSingleFileComments: false
[CheckstyleCheck] createCommentWithAllSingleFileComments: true
[CheckstyleCheck] CHECKSTYLE with pattern .*/target/checkstyle-result.xml
[CheckstyleCheck] CSSLINT with pattern null
[CheckstyleCheck] LINT with pattern null
[CheckstyleCheck] FINDBUGS with pattern null
[CheckstyleCheck] JSHINT with pattern null
[CheckstyleCheck] PMD with pattern null
[CheckstyleCheck] CPPCHECK with pattern null
[CheckstyleCheck] RESHARPER with pattern null
[CheckstyleCheck] FLAKE8 with pattern null
[CheckstyleCheck] CPPLINT with pattern null
[CheckstyleCheck] XMLLINT with pattern null
[CheckstyleCheck] PERLCRITIC with pattern null
[CheckstyleCheck] PITEST with pattern null
[CheckstyleCheck] ANDROIDLINT with pattern null
[CheckstyleCheck] Running Jenkins Violation Comments To Bitbucket Server
[CheckstyleCheck] Will comment 257
[CheckstyleCheck] Workspace: /jenkins/workspace/root_pipeline
[CheckstyleCheck] Found 5 violations from ViolationConfig [reporter=CHECKSTYLE, pattern=.*/target/checkstyle-result.xml].
[CheckstyleCheck] Jenkins has not been started, or was already shut down

Compare that to using user/password:

[FindbugsCheck] ---
[FindbugsCheck] --- Jenkins Violation Comments to Bitbucket Server ---
[FindbugsCheck] ---
[FindbugsCheck] bitbucketServerUrl: https://git.richrelevance.com
[FindbugsCheck] projectKey: RR
[FindbugsCheck] repoSlug: root
[FindbugsCheck] pullRequestId: 257
[FindbugsCheck] usernamePasswordCredentialsId: true
[FindbugsCheck] username: true
[FindbugsCheck] password: true
[FindbugsCheck] createSingleFileComments: true
[FindbugsCheck] createCommentWithAllSingleFileComments: false
[FindbugsCheck] CHECKSTYLE with pattern null
[FindbugsCheck] CSSLINT with pattern null
[FindbugsCheck] LINT with pattern null
[FindbugsCheck] FINDBUGS with pattern .*/target/findbugsXml.xml
[FindbugsCheck] JSHINT with pattern null
[FindbugsCheck] PMD with pattern null
[FindbugsCheck] CPPCHECK with pattern null
[FindbugsCheck] RESHARPER with pattern null
[FindbugsCheck] FLAKE8 with pattern null
[FindbugsCheck] CPPLINT with pattern null
[FindbugsCheck] XMLLINT with pattern null
[FindbugsCheck] PERLCRITIC with pattern null
[FindbugsCheck] PITEST with pattern null
[FindbugsCheck] ANDROIDLINT with pattern null
[FindbugsCheck] Running Jenkins Violation Comments To Bitbucket Server
[FindbugsCheck] Will comment 257
[FindbugsCheck] Workspace: /jenkins/workspace/root_pipeline
[FindbugsCheck] Found 3 violations from ViolationConfig [reporter=FINDBUGS, pattern=.*/target/findbugsXml.xml].
[FindbugsCheck] Using username / password
[FindbugsCheck] Will comment PR RR/root/257 on https://git.richrelevance.com

Here's the definition for both steps:

            step([$class: 'ViolationsToBitbucketServerRecorder',
                  config: [bitbucketServerUrl: 'https://git.richrelevance.com',
                           createCommentWithAllSingleFileComments: true, createSingleFileComments: false,
                           projectKey: PULL_REQUEST_TO_REPO_PROJECT_KEY, pullRequestId: PULL_REQUEST_ID,
                           repoSlug: PULL_REQUEST_TO_REPO_SLUG, useUsernamePassword: false,
                           useUsernamePasswordCredentials: true,
                           usernamePasswordCredentialsId: 'XXX',
                           violationConfigs: [[pattern: '.*/target/checkstyle-result.xml', reporter: 'CHECKSTYLE']]]])

            withCredentials([[$class: 'UsernamePasswordMultiBinding',
                              credentialsId: 'XXX',
                              passwordVariable: 'PASSWORD', usernameVariable: 'USERNAME']]) {
                step([$class: 'ViolationsToBitbucketServerRecorder',
                      config: [bitbucketServerUrl: 'https://git.richrelevance.com',
                               createCommentWithAllSingleFileComments: false, createSingleFileComments: true,
                               projectKey: PULL_REQUEST_TO_REPO_PROJECT_KEY, pullRequestId: PULL_REQUEST_ID,
                               repoSlug: PULL_REQUEST_TO_REPO_SLUG, useUsernamePassword: true,
                               useUsernamePasswordCredentials: false,
                               username: env.USERNAME,
                               password: env.PASSWORD,
                               usernamePasswordCredentialsId: 'XXX',
                               violationConfigs: [[pattern: '.*/target/findbugsXml.xml', reporter: 'FINDBUGS']]]])
            }

Note that on findbugs I'm setting both user/password and credentials, because I used Replay to test if the authentication mode made any difference.

Could you extend documentation how to comment at https://bitbucket.org

Try to use many ways but got nothing.

step([

        $class: 'ViolationsToBitbucketServerRecorder', 

            config: [

                bitbucketServerUrl: 'https://api.bitbucket.org/', 

                createCommentWithAllSingleFileComments: true, 

                createSingleFileComments: true, 

                projectKey: 'EVANTI', 

                repoSlug: 'cabinet-radugainternet-ru', 

                pullRequestId: "${pr}", 

                useUsernamePassword: true, 

                username: 'admin', 

                password: 'admin', 

                useUsernamePasswordCredentials: false, 

                violationConfigs: [

                    [ pattern: 'check_style.xml', reporter: 'CHECKSTYLE' ]

                ]

            ]

        ])

see at log

Error calling:

https://api.bitbucket.org/rest/api/1.0/projects/EVANTI/repos/cabinet-radugainternet-ru/pull-requests/683/changes?limit=999999
GET
 null

`

Violations Comment too long for Bitbucket Server

When the plugin posts a comment resulting from a particularly bad linting session (with tons of violations), the following error occurs:

{
  "errors": [
    {
      "context": "text",
      "message": "Please enter a non-empty value less than 32768 characters",
      "exceptionName": null
    }
  ]
}

Would it be possible to break up the posting of the comments into properly-sized chunks?

Bitbucket cloud support

Hi, does this plugin support work with bitbucket cloud, atlassian hosted repository?

I've tried various settings, but always see http error in logs:
{"type": "error", "error": {"message": "Resource not found", "detail": "There is no API hosted at this URL.\n\nFor information about our API's, please refer to the documentation at: https://developer.atlassian.com/bitbucket/api/2/reference/"}}

Pretty print violations comments

Violations comments could use some formatting. It's quite ugly now:

image

Maybe:

image

Or even:

image

(Table-formatting actually eats up some more space so not sure... but it looks nice).

Implement these with the following markdown:

**Reporter**: PYLINT
**Rule**: `0326`(bad-whitespace)
**Severity**: INFO
**File**: fs/csm/common/util.py L40

No space allowed around keyword argument assignment
*<this is a auto generated comment from violation-comments-lib F7F8ASD8123FSDF>*

| | |
|---|---|
| **Reporter** | PYLINT |
| **Rule** | `0326`(bad-whitespace) |
| **Severity** | INFO |
| **File** | fs/csm/common/util.py L40 |
| **Message** | No space allowed around keyword argument assignment |

*<this is a auto generated comment from violation-comments-lib F7F8ASD8123FSDF>*

Nothing seems to be happening, and no logging for debugging

I'm trying to use Viiolations to Bitbucket, but something isn't working there. It prints these lines:

Running Jenkins Violation Comments To Bitbucket Server
Will comment 724

But nothing happens on the pull request, and no other lines are printed after. I don't know if it found the violation files, if it recognized the contents, if it tried to make actual comments.

I'd like the plugin to print positive messages, such as saying "found checkstyle results. X violations." and "Nothing to report" or "X comments made".

Comments publish to PR fails to incorrect Stash API invocation

With 1.30, publishing comments to PR fails to:

Found 59 violations from ViolationConfig [reporter=PYLINT, pattern=.*/pylint\.out$].
Will comment PR COSMOS/cosmos/185 on https://mystash.gtn
java.lang.RuntimeException: Error calling:
https://mystash.gtn/rest/api/1.0/projects/COSMOS/repos/cosmos/pull-requests/185/comments
POST
{...SNIP CONTENTS...}
    at se.bjurr.violations.comments.bitbucketserver.lib.client.BitbucketServerInvoker.invokeUrl(BitbucketServerInvoker.java:56)
    at se.bjurr.violations.comments.bitbucketserver.lib.client.BitbucketServerClient.pullRequestComment(BitbucketServerClient.java:46)
    at se.bjurr.violations.comments.bitbucketserver.lib.BitbucketServerCommentsProvider.createCommentWithAllSingleFileComments(BitbucketServerCommentsProvider.java:43)
    at se.bjurr.violations.comments.lib.CommentsCreator.createCommentWithAllSingleFileComments(CommentsCreator.java:66)
    at se.bjurr.violations.comments.lib.CommentsCreator.createComments(CommentsCreator.java:50)
    at se.bjurr.violations.comments.lib.CommentsCreator.createComments(CommentsCreator.java:25)
    at se.bjurr.violations.comments.bitbucketserver.lib.ViolationCommentsToBitbucketServerApi.toPullRequest(ViolationCommentsToBitbucketServerApi.java:80)
    at org.jenkinsci.plugins.jvctb.perform.JvctbPerformer.doPerform(JvctbPerformer.java:91)
    at org.jenkinsci.plugins.jvctb.perform.JvctbPerformer$1.invoke(JvctbPerformer.java:155)
    at org.jenkinsci.plugins.jvctb.perform.JvctbPerformer$1.invoke(JvctbPerformer.java:142)
    at hudson.FilePath$FileCallableWrapper.call(FilePath.java:2772)
    at hudson.remoting.UserRequest.perform(UserRequest.java:153)
    at hudson.remoting.UserRequest.perform(UserRequest.java:50)
    at hudson.remoting.Request$2.run(Request.java:332)
    at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:68)
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.io.IOException: Server returned HTTP response code: 400 for URL: https://mystash.gtn/rest/api/1.0/projects/COSMOS/repos/cosmos/pull-requests/185/comments
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1876)
    at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1474)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.getInputStream(HttpsURLConnectionImpl.java:254)
    at se.bjurr.violations.comments.bitbucketserver.lib.client.BitbucketServerInvoker.invokeUrl(BitbucketServerInvoker.java:47)
    ... 18 more

Going to https://mystash.gtn/rest/api/1.0/projects/COSMOS/repos/cosmos/pull-requests/185/comments in browser (with credentials) gives 400 with body:

{"errors":[{"context":null,"message":"The path query parameter is required when retrieving comments.","exceptionName":null}]}

It seems like path query parameter is indeed required, see: https://jira.atlassian.com/browse/BSERV-7643 (that was closed as wontfix). That ticket leads to https://answers.atlassian.com/questions/21634693/answers/21634860. To retrieve also generic comments, the tickets suggest to use activation API instead:

/rest/api/1.0/projects/{projectKey}/repos/{repositorySlug}/pull-requests/{pullRequestId}/activities

Or, if general comments are not required, appending ?path=... to query seems to indeed pass the query (but it seems like you have to throw query per file..?).

Running Bitbucket Server 4.9.1.

Comment only violations that relate to a diff

It seems like the plugin now writes all violation comments that relate to a file in the diff.

The comments that don't have actual diff are left in the Overview-tab in the main stream (instead of showing up under Diff-tab).

It would be better to write just those comments, that relate to code that was actually changed?

"Outdated" comments not deleted

Hi,
I have seen the parameter keepOldComments and set it to false. I do not really know what this intended to mean, but I expected that all automatically created comments on that pull request are removed before comments for the recent build are added. However, this does not happen.

Now I have multiple comments with the identifier <this is a auto generated comment from violation-comments-lib F7F8ASD8123FSDF> <a945025467>, for example.

Did I understand this setting incorrectly?

Pattern 'filename\\.xml' at the root of the workspace is not found

When generating the cppcheck.xml file at the root of the workspace and setting the pattern to 'cppcheck\.xml' the plugin did not find the file. I had to set the pattern to '.*/*cppcheck\.xml$' to find it which took me some time.

Is it possible to change it or document it ?

Also for diagnostic it would help to log the name (or number) of file found as the log "Found 0 violations from ViolationConfig [reporter=CPPCHECK..." doesn't indicate if there was an empty file or if no file was found.

Thanks for the great plugin !

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.