Git Product home page Git Product logo

Comments (10)

tomasbjerre avatar tomasbjerre commented on September 23, 2024

Looks like there were not violations in the files that were changed in the pull request.

The Will comment PR does not mean there actually are violations in the changed content.

from violation-comments-to-stash-plugin.

MarsianMan avatar MarsianMan commented on September 23, 2024

Does commentOnlyChangedContent: false not mean it will comment all violations regardless of whether it is in changed content? If not, can you elaborate on what the option does?

from violation-comments-to-stash-plugin.

tomasbjerre avatar tomasbjerre commented on September 23, 2024

from violation-comments-to-stash-plugin.

little-fish avatar little-fish commented on September 23, 2024

Hello.
I am also stuck with the plugin commenting nothing, even though I was adding warnings on purpose.
I am using Multibranch pipeline project with declarative Jenkinsfile.
Here is the output from build console:

...
[Pipeline] sh
[jenkins-global_feature_jen3-432RALCCXJN5KCIZCIYY2LV3HP352XOLR63YXIH5Y6NRADEI57MA] Running shell script
+ ./gradlew check
...
> Task :common:checkstyleMain
Checkstyle rule violations were found. See the report at: file:///srv/jenkins/workspace/jenkins-global_feature_jen3-432RALCCXJN5KCIZCIYY2LV3HP352XOLR63YXIH5Y6NRADEI57MA/common/build/reports/checkstyle/main.html
Checkstyle files with violations: 1
Checkstyle violations by severity: [warning:2]
...
BUILD SUCCESSFUL in 14s
7 actionable tasks: 5 executed, 2 up-to-date
[Pipeline] checkstyle
[CHECKSTYLE] Collecting checkstyle analysis files...
[CHECKSTYLE] Searching for all files in /srv/jenkins/workspace/jenkins-global_feature_jen3-432RALCCXJN5KCIZCIYY2LV3HP352XOLR63YXIH5Y6NRADEI57MA that match the pattern **/reports/checkstyle/*.xml
[CHECKSTYLE] Parsing 2 files in /srv/jenkins/workspace/jenkins-global_feature_jen3-432RALCCXJN5KCIZCIYY2LV3HP352XOLR63YXIH5Y6NRADEI57MA
[CHECKSTYLE] Successfully parsed file /srv/jenkins/workspace/jenkins-global_feature_jen3-432RALCCXJN5KCIZCIYY2LV3HP352XOLR63YXIH5Y6NRADEI57MA/common/build/reports/checkstyle/main.xml with 2 unique warnings and 0 duplicates.
[CHECKSTYLE] Successfully parsed file /srv/jenkins/workspace/jenkins-global_feature_jen3-432RALCCXJN5KCIZCIYY2LV3HP352XOLR63YXIH5Y6NRADEI57MA/impl/build/reports/checkstyle/main.xml with 108 unique warnings and 0 duplicates.
Skipping warnings blame since pipelines do not have an SCM link.%n
[CHECKSTYLE] Computing warning deltas based on reference build #2
[Pipeline] findbugs
[FINDBUGS] Collecting findbugs analysis files...
[FINDBUGS] Searching for all files in /srv/jenkins/workspace/jenkins-global_feature_jen3-432RALCCXJN5KCIZCIYY2LV3HP352XOLR63YXIH5Y6NRADEI57MA that match the pattern **/reports/findbugs/*.xml
[FINDBUGS] Parsing 2 files in /srv/jenkins/workspace/jenkins-global_feature_jen3-432RALCCXJN5KCIZCIYY2LV3HP352XOLR63YXIH5Y6NRADEI57MA
[FINDBUGS] Successfully parsed file /srv/jenkins/workspace/jenkins-global_feature_jen3-432RALCCXJN5KCIZCIYY2LV3HP352XOLR63YXIH5Y6NRADEI57MA/common/build/reports/findbugs/main.xml with 0 unique warnings and 0 duplicates.
Skipping warnings blame since pipelines do not have an SCM link.%n
[FINDBUGS] Computing warning deltas based on reference build #2
...
[Pipeline] step
---
--- Jenkins Violation Comments to Bitbucket Server ---
---
bitbucketServerUrl: https://***/bitbucket
projectKey: JEN
repoSlug: jenkins
pullRequestId: 14
credentialsId: true
createSingleFileComments: true
createCommentWithAllSingleFileComments: true
commentOnlyChangedContent: false
commentOnlyChangedContentContext: 5
minSeverity: INFO
keepOldComments: false
Pull request: 14
Workspace: /srv/jenkins/workspace/jenkins-global_feature_jen3-432RALCCXJN5KCIZCIYY2LV3HP352XOLR63YXIH5Y6NRADEI57MA
PR: JEN/jenkins/14 on https://***/bitbucket
[Pipeline] }
...

I have tried to add additional logger through Jenkins web GUI with logger 'org.jenkinsci.plugins.jvctb' set to ALL, but had no luck.
Can you please poke me the right direction?

Thank you very much for your help.

from violation-comments-to-stash-plugin.

tomasbjerre avatar tomasbjerre commented on September 23, 2024

How did you configure the plugin? Looks like you have no patterns defined.
How did you configure the job? Do you perform the merge before check

from violation-comments-to-stash-plugin.

little-fish avatar little-fish commented on September 23, 2024

Important stages from my Jenkinsfile:

stages {
        stage('Print parameters') {
            steps {
                echo "pullRequestId='$params.pullRequestId'"
                echo "toBranch='$params.toBranch'"
                echo "toHash='$params.toHash'"
                echo "mergeCommit='$params.mergeCommit'"
                echo "fromHash='$params.fromHash'"
                echo "action='$params.action'"
                echo "author='$params.author'"
                echo "reviewers='$params.reviewers'"
            }
        }

        stage('Read commit and branch') {
            when {
                expression { params.pullRequestId }
            }
            // commit hash is used later
            steps {
                sh 'git rev-parse HEAD > commit'
                echo "On branch ${env.BRANCH_NAME} commit ${readFile('commit').trim()}."
            }
        }

        stage('Merge pull request') {
            // when we know a pull request target we merge it
            when {
                expression { params.toHash }
            }
            steps {
                echo "Merging commit ${readFile('commit').trim()} with commit ${params.toHash}"
                sh "git reset --hard ${params.toHash}"
                sh "git merge ${readFile('commit').trim()} --no-commit"
            }
        }

        stage('Static analysis') {
            steps {
                echo 'Running static analysis...'
                sh './gradlew check'
            }
            post {
                always {
                    checkstyle pattern: '**/reports/checkstyle/*.xml'
                    findbugs pattern: '**/reports/findbugs/*.xml'
                }
            }
        }

        stage('Report violations') {
            steps {
                echo "Reporting static analysis violations for pull request ${params.pullRequestId}."
                step([
                        $class: 'ViolationsToBitbucketServerRecorder',
                        config: [
                                bitbucketServerUrl: 'https://***/bitbucket',
                                createCommentWithAllSingleFileComments: true,
                                createSingleFileComments: true,
                                commentOnlyChangedContent: false,
                                commentOnlyChangedContentContext: 5,
                                pullRequestId: params.pullRequestId,
                                useUsernamePassword: false,
                                username: '',
                                password: '',
                                useUsernamePasswordCredentials: true,
                                credentialsId: 'b90c9363-25b9-4ebe-834e-f4f485a24bd7',
                                projectKey: 'JEN',
                                repoSlug: 'jenkins',
                                violationConfigs: [
                                        [ pattern: '.*/checkstyle/.*\\.xml$', reporter: 'CHECKSTYLE' ],
                                        [ pattern: '.*/findbugs/.*\\.xml$', reporter: 'FINDBUGS' ]
                                ]
                        ]
                ])
            }
        }
    }

Adding some additional info from Jenkins build output:

ullRequestId='14'
toBranch='develop'
toHash='99eb9f28280a04a6cc20b3dc4b63a71031f8cd55'
fromHash='d40a7eaf2b38207aca3e7dee28b4c417b7e4fd2b'
action='RESCOPED_FROM'
...
[Pipeline] stage
[Pipeline] { (Read commit and branch)
[Pipeline] sh
[jenkins-global_feature_jen3-432RALCCXJN5KCIZCIYY2LV3HP352XOLR63YXIH5Y6NRADEI57MA] Running shell script
+ git rev-parse HEAD
[Pipeline] readFile
[Pipeline] echo
On branch feature/jen3 commit d40a7eaf2b38207aca3e7dee28b4c417b7e4fd2b.
[Pipeline] }
...
[Pipeline] stage
[Pipeline] { (Merge pull request)
[Pipeline] readFile
[Pipeline] echo
Merging commit d40a7eaf2b38207aca3e7dee28b4c417b7e4fd2b with commit 99eb9f28280a04a6cc20b3dc4b63a71031f8cd55
[Pipeline] sh
[jenkins-global_feature_jen3-432RALCCXJN5KCIZCIYY2LV3HP352XOLR63YXIH5Y6NRADEI57MA] Running shell script
+ git reset --hard 99eb9f28280a04a6cc20b3dc4b63a71031f8cd55
HEAD is now at 99eb9f2 Merge pull request #13 in JEN/jenkins from feature/jen2 to develop
[Pipeline] readFile
[Pipeline] sh
[jenkins-global_feature_jen3-432RALCCXJN5KCIZCIYY2LV3HP352XOLR63YXIH5Y6NRADEI57MA] Running shell script
+ git merge d40a7eaf2b38207aca3e7dee28b4c417b7e4fd2b --no-commit
Automatic merge went well; stopped before committing as requested
Auto-merging Jenkinsfile
[Pipeline] }

So merge is done and xml files have been created with check.
Thank you.

from violation-comments-to-stash-plugin.

tomasbjerre avatar tomasbjerre commented on September 23, 2024

What version of the plugin?

from violation-comments-to-stash-plugin.

little-fish avatar little-fish commented on September 23, 2024

v1.70

from violation-comments-to-stash-plugin.

tomasbjerre avatar tomasbjerre commented on September 23, 2024

You are missing this logging:
https://github.com/jenkinsci/violation-comments-to-stash-plugin/blob/master/src/main/java/org/jenkinsci/plugins/jvctb/perform/JvctbPerformer.java#L256

Change:

violationConfigs: [
 [ pattern: '.*/checkstyle/.*\\.xml$', reporter: 'CHECKSTYLE' ],
 [ pattern: '.*/findbugs/.*\\.xml$', reporter: 'FINDBUGS' ]
 ]

To:

violationConfigs: [
 [ pattern: '.*/checkstyle/.*\\.xml$', reporter: 'CHECKSTYLE' , parser: 'CHECKSTYLE' ],
 [ pattern: '.*/findbugs/.*\\.xml$', reporter: 'FINDBUGS' , parser: 'FINDBUGS' ]
]

This should definitely be changed to an exception in the log instead of silent ignore...

from violation-comments-to-stash-plugin.

little-fish avatar little-fish commented on September 23, 2024

Holy.. I somehow missed the parsers. Now it works! Thanks a million!!! You have just saved my day!

from violation-comments-to-stash-plugin.

Related Issues (20)

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.