github-integration-plugin icon indicating copy to clipboard operation
github-integration-plugin copied to clipboard

NullPointerException in StatusVerifier.isRunAllowed

Open BlackHornet opened this issue 7 years ago • 7 comments

Hi,

I have a problem setting up the gitRPStatusPublisher in my declarative pipeline, the following exception is thrown:

java.lang.NullPointerException
	at org.jenkinsci.plugins.github.pullrequest.utils.StatusVerifier.isRunAllowed(StatusVerifier.java:27)
	at org.jenkinsci.plugins.github.pullrequest.publishers.impl.GitHubPRBuildStatusPublisher.perform(GitHubPRBuildStatusPublisher.java:79)
	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)

in my declarative pipeline I have a build stage configured like this:

        stage('Build') {
            steps {
                echo "Perform Build"
                sh "./gradlew assemble"
            }
            post {
                always {
                    githubPRStatusPublisher buildMessage: message(failureMsg: githubPRMessage('Can\'t set status; build failed.'), successMsg: githubPRMessage('Can\'t set status; build succeeded.')), errorHandler: statusOnPublisherError('UNSTABLE'), statusMsg: githubPRMessage('${GITHUB_PR_COND_REF} run ended'), statusVerifier: allowRunOnStatus('SUCCESS'), unstableAs: 'FAILURE'
                }
            }
        }

For the githubPRStatusPublisher call I used the pipeline syntax tool creating the command.

Is there anything I miss-configured for my the job?

BlackHornet avatar Jul 23 '18 08:07 BlackHornet

same issue here

Error when executing success post condition:
java.lang.NullPointerException
	at org.jenkinsci.plugins.github.pullrequest.utils.StatusVerifier.isRunAllowed(StatusVerifier.java:27)
	at org.jenkinsci.plugins.github.pullrequest.publishers.impl.GitHubPRCommentPublisher.perform(GitHubPRCommentPublisher.java:59)
	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)

Jenkins ver. 2.136 GitHub Integration Plugin 0.2.3

robgott avatar Sep 02 '18 05:09 robgott

Looks like run.getResult() is null. It seems that workflow job doesn't set run status because user should control it itself? Existing code do null check for statusVerifier field. Try not set it statusVerifier: allowRunOnStatus('SUCCESS') at all and control workflow flow with workflow code logic.

KostyaSha avatar Dec 11 '18 00:12 KostyaSha

Running into the same issue. I've tried running with and without statusVerifier set to various things. If I don't set statusVerifier to anything, Jenkins complains I'm not setting a necessary parameter. If I do set it to anything, I get the NPE. What's the deal?

brightshine1111 avatar Jun 26 '19 22:06 brightshine1111

If I don't set statusVerifier to anything, Jenkins complains I'm not setting a necessary parameter

could you show the log?

KostyaSha avatar Jun 26 '19 22:06 KostyaSha

There is any update with the issue, I am failing on the same thing

githubPRStatusPublisher buildMessage: message(failureMsg: githubPRMessage('build failed.'), successMsg: githubPRMessage('build succeeded.')), errorHandler: statusOnPublisherError('FAILURE'), statusMsg: githubPRMessage('Build #${BUILD_NUMBER} ended'), statusVerifier: allowRunOnStatus('SUCCESS'), unstableAs: 'FAILURE'

Jenkins ver. 2.187 GitHub Integration Plugin 0.2.6

nivg1992 avatar Jul 24 '19 14:07 nivg1992

Same issue for me Jenkins: 2.176.3 GitHub Integration Plugin: 0.2.6

dtkachenko avatar Nov 22 '19 19:11 dtkachenko

There is any update with the issue, I am failing on the same thing

githubPRStatusPublisher buildMessage: message(failureMsg: githubPRMessage('build failed.'), successMsg: githubPRMessage('build succeeded.')), errorHandler: statusOnPublisherError('FAILURE'), statusMsg: githubPRMessage('Build #${BUILD_NUMBER} ended'), statusVerifier: allowRunOnStatus('SUCCESS'), unstableAs: 'FAILURE'

Jenkins ver. 2.187 GitHub Integration Plugin 0.2.6

maybe it late :) githubPRStatusPublisher have to put in post section. ex:

post {
     always{
githubPRStatusPublisher buildMessage: message(failureMsg: githubPRMessage('Can\'t set status; build failed.'), successMsg: githubPRMessage('Can\'t set status; build succeeded.')), statusMsg: githubPRMessage('${GITHUB_PR_COND_REF} run ended'), statusVerifier: allowRunOnStatus('SUCCESS'), errorHandler: statusOnPublisherError('FAILURE'), unstableAs: 'FAILURE'
     }
}

logigearminhduytran avatar Dec 01 '22 09:12 logigearminhduytran