[JIRA] (JENKINS-42226) NPE in branch condition

2 views
Skip to first unread message

domi@fortysix.ch (JIRA)

unread,
Feb 21, 2017, 11:56:01 AM2/21/17
to jenkinsc...@googlegroups.com
Dominik Bartholdi created an issue
 
Jenkins / Bug JENKINS-42226
NPE in branch condition
Issue Type: Bug Bug
Assignee: Andrew Bayer
Components: pipeline-model-definition-plugin
Created: 2017/Feb/21 4:55 PM
Priority: Minor Minor
Reporter: Dominik Bartholdi

This pipeline fails with a NullPointerException:

config = [:]

pipeline {
    agent any
    stages {
        stage ('prepare') {
            when {
                branch config.branch
            }
            steps {
                echo "hello branch"            
            }
        }
    }
}

exception:

java.lang.NullPointerException
	at org.jenkinsci.plugins.pipeline.modeldefinition.when.impl.BranchConditional.branchMatches(BranchConditional.java:64)
	at org.jenkinsci.plugins.pipeline.modeldefinition.when.impl.BranchConditional$branchMatches.call(Unknown Source)
	at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
	at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
	at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:18)
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.1.7#71011-sha1:2526d7c)
Atlassian logo

domi@fortysix.ch (JIRA)

unread,
Feb 21, 2017, 11:59:01 AM2/21/17
to jenkinsc...@googlegroups.com
Dominik Bartholdi updated an issue
Change By: Dominik Bartholdi
This pipeline fails with a {{NullPointerException}}:

{noformat}


config = [:]

pipeline {
    agent any
    stages {
        stage ('prepare') {
            when {
                branch config.branch
            }
            steps {
                echo "hello branch"            
            }
        }
    }
}
{noformat}

I know, the pipeline might look a bit strange with having a config/map defined - but in our real pipeline, we have some logic to select the correct config/map object before the pipeline starts. This allows us to reuse a lot more...


exception:

{noformat}

java.lang.NullPointerException
at org.jenkinsci.plugins.pipeline.modeldefinition.when.impl.BranchConditional.branchMatches(BranchConditional.java:64)
at org.jenkinsci.plugins.pipeline.modeldefinition.when.impl.BranchConditional$branchMatches.call(Unknown Source)
at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
at com.cloudbees.groovy.cps.sandbox.DefaultInvoker.methodCall(DefaultInvoker.java:18)
{noformat}

andrew.bayer@gmail.com (JIRA)

unread,
Feb 21, 2017, 12:00:03 PM2/21/17
to jenkinsc...@googlegroups.com
Andrew Bayer commented on Bug JENKINS-42226
 
Re: NPE in branch condition

Ah-ha - should be an easy fix

andrew.bayer@gmail.com (JIRA)

unread,
Feb 21, 2017, 12:03:01 PM2/21/17
to jenkinsc...@googlegroups.com
Andrew Bayer started work on Bug JENKINS-42226
 
Change By: Andrew Bayer
Status: Open In Progress

andrew.bayer@gmail.com (JIRA)

unread,
Feb 21, 2017, 12:08:03 PM2/21/17
to jenkinsc...@googlegroups.com
Change By: Andrew Bayer
Status: In Review Progress

andrew.bayer@gmail.com (JIRA)

unread,
Feb 21, 2017, 12:08:04 PM2/21/17
to jenkinsc...@googlegroups.com

andrew.bayer@gmail.com (JIRA)

unread,
Feb 21, 2017, 12:08:04 PM2/21/17
to jenkinsc...@googlegroups.com
Change By: Andrew Bayer
Status: In Progress Review

andrew.bayer@gmail.com (JIRA)

unread,
Feb 21, 2017, 12:08:05 PM2/21/17
to jenkinsc...@googlegroups.com

scm_issue_link@java.net (JIRA)

unread,
Feb 21, 2017, 1:20:02 PM2/21/17
to jenkinsc...@googlegroups.com

Code changed in jenkins
User: Andrew Bayer
Path:
pipeline-model-definition/src/main/java/org/jenkinsci/plugins/pipeline/modeldefinition/when/impl/BranchConditional.java
pipeline-model-definition/src/test/java/org/jenkinsci/plugins/pipeline/modeldefinition/BasicModelDefTest.java
pipeline-model-definition/src/test/resources/whenBranchNull.groovy
http://jenkins-ci.org/commit/pipeline-model-definition-plugin/c32520a90a360e6b3d9f6700d56bbca45f74d0b3
Log:
[FIXED JENKINS-42226] Treat null/empty branch comparison as false

andrew.bayer@gmail.com (JIRA)

unread,
Feb 21, 2017, 1:21:01 PM2/21/17
to jenkinsc...@googlegroups.com
Change By: Andrew Bayer
Status: In Review Resolved
Resolution: Fixed

domi@fortysix.ch (JIRA)

unread,
Feb 22, 2017, 3:00:01 AM2/22/17
to jenkinsc...@googlegroups.com

bitwiseman@gmail.com (JIRA)

unread,
Oct 22, 2019, 11:24:08 PM10/22/19
to jenkinsc...@googlegroups.com
Liam Newman closed an issue as Fixed
 

Bulk closing resolved issues.

Change By: Liam Newman
Status: Resolved Closed
This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo
Reply all
Reply to author
Forward
0 new messages