[JIRA] (JENKINS-57775) NullPointerException when scan bitbucket mulit-branch

17 views
Skip to first unread message

linuxsuren@gmail.com (JIRA)

unread,
May 31, 2019, 12:35:01 AM5/31/19
to jenkinsc...@googlegroups.com
Rick created an issue
 
Jenkins / Bug JENKINS-57775
NullPointerException when scan bitbucket mulit-branch
Issue Type: Bug Bug
Assignee: Rick
Attachments: image-2019-05-31-12-33-54-393.png
Components: bitbucket-branch-source-plugin
Created: 2019-05-31 04:34
Priority: Major Major
Reporter: Rick

This will happen when there are some PRs that don't have any commits.

Add Comment Add Comment
 
This message was sent by Atlassian Jira (v7.11.2#711002-sha1:fdc329d)

michelzanini@gmail.com (JIRA)

unread,
Jul 19, 2019, 2:24:02 PM7/19/19
to jenkinsc...@googlegroups.com
Michel Zanini commented on Bug JENKINS-57775
 
Re: NullPointerException when scan bitbucket mulit-branch

This bug is a duplication of https://issues.jenkins-ci.org/browse/JENKINS-56309.
I am also experiencing this and will report steps on how to reproduce.

michelzanini@gmail.com (JIRA)

unread,
Jul 19, 2019, 2:38:02 PM7/19/19
to jenkinsc...@googlegroups.com

To reproduce the issue above, on Bitbucket Cloud, follow the steps:

  • Create a new branch, here we will create a branch called develop.
  • No need to do any commits to it, create another branch from develop, we can call it my_changes
  • Commit something to my_changes
  • Create a PR from my_changes to ** develop**
  • Go to Jenkins and see that there are builds for both branches and the PR
  • Now open Bitbucket Cloud and delete the develop - don't decline the PR (leave it open)
  • Now when opening the PR there will be zero commits on the PR (the target branch no longer exists)
  • Go back to Jenkins multi-branch pipeline and press Scan Multibranch Pipeline Log
  • **When the plugin is canning the PRs it will fail with the exception reported here

The cause:

The API call done to get all pull requests is made from:

 

BitbucketCloudApiClient.getPullRequests()

In the this call, the JSON is parsed to:

 

 

-> BitbucketPullRequests
   -> List<BitbucketPullRequestValue> values;
        -> BitbucketPullRequestValueDestination destination;

And BitbucketPullRequestValueDestination class has this constructor: 

 

 

@JsonCreator
public BitbucketPullRequestValueDestination(@NonNull @JsonProperty("repository") BitbucketCloudRepository repository,
                                            @NonNull @JsonProperty("branch") BitbucketCloudBranch branch,
                                            @NonNull @JsonProperty("commit") BitbucketCloudCommit commit) {
    this.repository = repository;
    this.branch = branch;
    this.commit = commit;

    // redound available the informations into impl objects
    this.branch.setRawNode(commit.getHash());
}

You can see here:

 

 

@NonNull @JsonProperty("commit") BitbucketCloudCommit commit

The @NotNull here is what is causing the exception. The JSON is returning null for commit. See:

 

 

...
            "destination": {
                "commit": null,
                "repository": {
                    "links": {
                        ...
                    },
                    "type": "repository",
                    "name": "my-demo-project",
                    "full_name": "my/my-demo-project",
                    "uuid": "{asdsdsd-5b91-44e5-9f76-af5612323123}"
                },
                "branch": {
                    "name": "develop"
                }
            },
...

I could create a PR to make BitbucketCloudCommit commit nullable.

But, this field is used in 5 different places, a few of them with a null check.

It is more work then just making it nullable, I think we might want to filter out PRs with no destination commit and remove then from Jenkins multi-branch jobs...

Joseph Petersen - if you could fix this it would be great.

 

-> Workaround is to manually decline the PR on Bitbucket.

 

 

Reply all
Reply to author
Forward
0 new messages