Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting null pointer exception on comment #23

Closed
Arbuzov opened this issue Oct 8, 2019 · 18 comments
Closed

Getting null pointer exception on comment #23

Arbuzov opened this issue Oct 8, 2019 · 18 comments
Labels

Comments

@Arbuzov
Copy link

Arbuzov commented Oct 8, 2019

Plugin version 2.31
Jenkins version 2.138.3
Gitlab 10.7.3 ce

Pipeline command

        step([
          $class: 'ViolationsToGitLabRecorder',
          config: [
            gitLabUrl: 'https://mygitlabserver/',
            projectId: 'projectgroup/project-name',
            mergeRequestIid: env.gitlabMergeRequestIid,
            //createCommentWithAllSingleFileComments: true,
            createSingleFileComments: true,
            //commentOnlyChangedContent: true,
            commentOnlyChangedFiles: true,
            minSeverity: 'INFO',
            maxNumberOfViolations: 99999,
            enableLogging: true,
            apiTokenCredentialsId: 'jenkins-violations-secret',
            apiTokenPrivate: true,
            authMethodHeader: true,
            ignoreCertificateErrors: 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: [
              [ pattern: '.*checkstyle\\.xml$', parser: 'CHECKSTYLE', reporter: 'Checkstyle' ]
            ]
          ]
        ])

Stack trace during the build

java.lang.NullPointerException
	at se.bjurr.violations.comments.gitlab.lib.GitLabCommentsProvider.createSingleFileComment(GitLabCommentsProvider.java:161)
	at se.bjurr.violations.comments.lib.CommentsCreator.createSingleFileComments(CommentsCreator.java:147)
	at se.bjurr.violations.comments.lib.CommentsCreator.createComments(CommentsCreator.java:71)
	at se.bjurr.violations.comments.lib.CommentsCreator.createComments(CommentsCreator.java:38)
	at se.bjurr.violations.comments.gitlab.lib.ViolationCommentsToGitLabApi.toPullRequest(ViolationCommentsToGitLabApi.java:175)
	at org.jenkinsci.plugins.jvctgl.perform.JvctglPerformer.doPerform(JvctglPerformer.java:160)
	at org.jenkinsci.plugins.jvctgl.perform.JvctglPerformer$2.invoke(JvctglPerformer.java:268)
	at org.jenkinsci.plugins.jvctgl.perform.JvctglPerformer$2.invoke(JvctglPerformer.java:256)
	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3052)
	at hudson.remoting.UserRequest.perform(UserRequest.java:212)
	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
	at hudson.remoting.Request$2.run(Request.java:369)
	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
	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)
@tomasbjerre
Copy link
Contributor

tomasbjerre commented Oct 8, 2019 via email

@tomasbjerre
Copy link
Contributor

Releasing 2.32 that should give a clearer error, but still not solving the issue.

@tomasbjerre tomasbjerre added the bug label Oct 8, 2019
@Arbuzov
Copy link
Author

Arbuzov commented Oct 9, 2019

It happens with every MR

@tomasbjerre
Copy link
Contributor

Did you try the new version? What is the new error?

@MarcJose
Copy link

MarcJose commented Oct 9, 2019

The current error seems to be the same (on version 2.32):

04:37:49 ---
04:37:49 --- Violation Comments to GitLab ---
04:37:49 ---
04:37:49 gitLabUrl: null
04:37:49 projectId: 
04:37:49 mergeRequestIid: 
04:37:49 apiTokenCredentialsId: true
04:37:49 ignoreCertificateErrors: false
04:37:49 apiTokenPrivate: false
04:37:49 authMethodHeader: false
04:37:49 createCommentWithAllSingleFileComments: true
04:37:49 createSingleFileComments: false
04:37:49 commentOnlyChangedContent: false
04:37:49 commentOnlyChangedFiles: false
04:37:49 maxNumberOfViolations:null
04:37:49 minSeverity: WARN
04:37:49 keepOldComments: false
04:37:49 shouldSetWip: true
04:37:49 commentTemplate: 
04:37:49 proxyUri: 
04:37:49 proxyCredentialsId: no
04:37:49 CHECKSTYLE with pattern .*/build/reports/checkstyle/.*\.html$
04:37:49 CPD with pattern .*/build/reports/cpd/.*\.text$
04:37:49 FINDBUGS with pattern .*/build/reports/spotbugs/.*\.html$
04:37:49 PMD with pattern .*/build/reports/pmd/.*\.html$
04:37:49 Running Violation Comments To GitLab
04:37:49 Merge request: 
04:37:49 Workspace: /var/lib/jenkins/workspace/group/project
04:37:49 Found 0 violations from ViolationConfig [pattern=.*/build/reports/checkstyle/.*\.html$, parser=CHECKSTYLE, reporter=].
04:37:49 Found 0 violations from ViolationConfig [pattern=.*/build/reports/cpd/.*\.text$, parser=CPD, reporter=].
04:37:49 Found 0 violations from ViolationConfig [pattern=.*/build/reports/spotbugs/.*\.html$, parser=FINDBUGS, reporter=].
04:37:49 Found 0 violations from ViolationConfig [pattern=.*/build/reports/pmd/.*\.html$, parser=PMD, reporter=].
04:37:49 Will comment PR null  
04:37:49 java.lang.NumberFormatException: For input string: ""
04:37:49 	at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
04:37:49 	at java.base/java.lang.Integer.parseInt(Integer.java:662)
04:37:49 	at java.base/java.lang.Integer.parseInt(Integer.java:770)
04:37:49 	at org.jenkinsci.plugins.jvctgl.perform.JvctglPerformer.doPerform(JvctglPerformer.java:115)
04:37:49 	at org.jenkinsci.plugins.jvctgl.perform.JvctglPerformer$2.invoke(JvctglPerformer.java:268)
04:37:49 	at org.jenkinsci.plugins.jvctgl.perform.JvctglPerformer$2.invoke(JvctglPerformer.java:256)
04:37:49 	at hudson.FilePath.act(FilePath.java:1078)
04:37:49 	at hudson.FilePath.act(FilePath.java:1061)
04:37:49 	at org.jenkinsci.plugins.jvctgl.perform.JvctglPerformer.jvctsPerform(JvctglPerformer.java:255)
04:37:49 	at org.jenkinsci.plugins.jvctgl.ViolationsToGitLabRecorder.perform(ViolationsToGitLabRecorder.java:62)
04:37:49 	at hudson.tasks.BuildStepCompatibilityLayer.perform(BuildStepCompatibilityLayer.java:79)
04:37:49 	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
04:37:49 	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
04:37:49 	at hudson.model.AbstractBuild$AbstractBuildExecution.performAllBuildSteps(AbstractBuild.java:690)
04:37:49 	at hudson.model.Build$BuildExecution.post2(Build.java:186)
04:37:49 	at hudson.model.AbstractBuild$AbstractBuildExecution.post(AbstractBuild.java:635)
04:37:49 	at hudson.model.Run.execute(Run.java:1840)
04:37:49 	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
04:37:49 	at hudson.model.ResourceController.execute(ResourceController.java:97)
04:37:49 	at hudson.model.Executor.run(Executor.java:429)
04:37:49 
04:37:49 Failed to update Gitlab commit status: No credentials found for credentialsId: 

@tomasbjerre
Copy link
Contributor

No that is very different stacktrace. Now you are missing project and merge request iid:

04:37:49 gitLabUrl: null
04:37:49 projectId: 
04:37:49 mergeRequestIid: 
04:37:49 apiTokenCredentialsId: true

@MarcJose
Copy link

MarcJose commented Oct 9, 2019

hmm shouldnt it use the global one by default?
Alright my bad actually... I looked at the wrong fields sorry.

@Arbuzov
Copy link
Author

Arbuzov commented Oct 9, 2019

Sorry.
Had some issues with the hardware. This is the new stacktrace

INFO Asking GitLabCommentsProvider to comment:
Post stage
[Pipeline] sh
INFO Checkstyle WARN jshint.W064 api/routes/sites/{site_id}.js 11 
java.lang.NullPointerException: diffRefs is null for MR with Iid 320 in projectId 780
	at java.util.Objects.requireNonNull(Objects.java:228)
	at se.bjurr.violations.comments.gitlab.lib.GitLabCommentsProvider.createSingleFileComment(GitLabCommentsProvider.java:172)
	at se.bjurr.violations.comments.lib.CommentsCreator.createSingleFileComments(CommentsCreator.java:147)
	at se.bjurr.violations.comments.lib.CommentsCreator.createComments(CommentsCreator.java:71)
	at se.bjurr.violations.comments.lib.CommentsCreator.createComments(CommentsCreator.java:38)
	at se.bjurr.violations.comments.gitlab.lib.ViolationCommentsToGitLabApi.toPullRequest(ViolationCommentsToGitLabApi.java:176)
	at org.jenkinsci.plugins.jvctgl.perform.JvctglPerformer.doPerform(JvctglPerformer.java:160)
	at org.jenkinsci.plugins.jvctgl.perform.JvctglPerformer$2.invoke(JvctglPerformer.java:268)
	at org.jenkinsci.plugins.jvctgl.perform.JvctglPerformer$2.invoke(JvctglPerformer.java:256)
	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3052)
	at hudson.remoting.UserRequest.perform(UserRequest.java:212)
	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
	at hudson.remoting.Request$2.run(Request.java:369)
	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
	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)

@tomasbjerre
Copy link
Contributor

What is the response of this?
https://mygitlabserver/api/v4/projects/780/merge_requests/320/changes

@Arbuzov
Copy link
Author

Arbuzov commented Oct 9, 2019

Please find attached all response in the archive
changes.json.zip

@tomasbjerre
Copy link
Contributor

Released 2.34 now. Should fix the problem. Available in the update site within hours.

@Arbuzov
Copy link
Author

Arbuzov commented Oct 9, 2019

I am afraid not yet.

INFO Asking GitLabCommentsProvider to comment:
INFO Checkstyle WARN jshint.W064 api/routes/sites/{site_id}.js 11 
java.lang.NullPointerException: diffRefs is null for MR with Iid 320 in projectId 780
	at java.util.Objects.requireNonNull(Objects.java:228)
	at se.bjurr.violations.comments.gitlab.lib.GitLabCommentsProvider.createSingleFileComment(GitLabCommentsProvider.java:177)
	at se.bjurr.violations.comments.lib.CommentsCreator.createSingleFileComments(CommentsCreator.java:147)
	at se.bjurr.violations.comments.lib.CommentsCreator.createComments(CommentsCreator.java:71)
	at se.bjurr.violations.comments.lib.CommentsCreator.createComments(CommentsCreator.java:38)
	at se.bjurr.violations.comments.gitlab.lib.ViolationCommentsToGitLabApi.toPullRequest(ViolationCommentsToGitLabApi.java:176)
	at org.jenkinsci.plugins.jvctgl.perform.JvctglPerformer.doPerform(JvctglPerformer.java:160)
	at org.jenkinsci.plugins.jvctgl.perform.JvctglPerformer$2.invoke(JvctglPerformer.java:268)
	at org.jenkinsci.plugins.jvctgl.perform.JvctglPerformer$2.invoke(JvctglPerformer.java:256)
	at hudson.FilePath$FileCallableWrapper.call(FilePath.java:3052)
	at hudson.remoting.UserRequest.perform(UserRequest.java:212)
	at hudson.remoting.UserRequest.perform(UserRequest.java:54)
	at hudson.remoting.Request$2.run(Request.java:369)
	at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
	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)

changes2.json.zip

Full log in zip to avoid search indexing

full.log.zip

@tomasbjerre
Copy link
Contributor

Strange, what is the response of this?
https://mygitlabserver/api/v4/projects/780/merge_requests/320

@Arbuzov
Copy link
Author

Arbuzov commented Oct 10, 2019

See attached
320.zip

@tomasbjerre
Copy link
Contributor

tomasbjerre commented Oct 10, 2019

The problem is that diff_refs is missing in your version of Gitlab. Not sure why.

In Gitlab.com it is there:
https://gitlab.com/api/v4/projects/2732496/merge_requests/1
and also in /changes:
https://gitlab.com/api/v4/projects/2732496/merge_requests/1/changes

It should also be there according to the docs:
https://docs.gitlab.com/ce/api/merge_requests.html#get-single-mr
https://docs.gitlab.com/ee/api/merge_requests.html#get-single-mr

@tomasbjerre
Copy link
Contributor

I tried Gitlab 10.7.3 and I can also see that diff_refs is missing. Could be a bug in that version. I would suggest upgrading Gitlab.

@Arbuzov
Copy link
Author

Arbuzov commented Oct 10, 2019

Thanks a lot for the clarification.
I will try to update my Gitlab next Monday and write the result here.

@Arbuzov
Copy link
Author

Arbuzov commented Oct 14, 2019

I updated my gitlab instance to 12.3.5 and the issue was fixed.
Thanks a lot for your help

@Arbuzov Arbuzov closed this as completed Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants