danger / kotlin

⚠️ Stop saying "you forgot to …" in code review
MIT License
504 stars 49 forks source link

NullPointerException bitBucketServer #213

Open vchernyshov opened 2 years ago

vchernyshov commented 2 years ago

I'm getting this error:

java.lang.NullPointerException

        at systems.danger.kotlin.models.danger.DangerDSL.getBitBucketServer(DangerDSL.kt:27)
        at Dangerfile_df.<init>(Dangerfile.df.kts:9)

This is my danger file:

@file:Repository("https://repo.maven.apache.org")
@file:DependsOn("org.apache.commons:commons-text:1.6")

import org.apache.commons.text.WordUtils
import systems.danger.kotlin.*
import systems.danger.kotlin.models.danger.DangerDSL

danger(args) {
    if (bitBucketServer.pullRequest.title.contains("WIP", false)) {
        warn("PR is classed as Work in Progress")
    }
}

Any ideas why it could happen?

f-meloni commented 2 years ago

It seems that the bitBucketServer object in your DSL is null.

What is the output of danger-kotlin pr $YOUR_PR_LINK --json?

vchernyshov commented 2 years ago

@f-meloni here is the json structure:

Screenshot 2022-04-10 at 09 04 14

according to source code _bitBucketServer is serialised with key bitbucket_server so looks like danger-kotlin doesn't support bitbucket_cloud

f-meloni commented 2 years ago

Yes, it should be simple to fix that, but it seems that Danger Kotlin is not supporting bitbucket_cloud at the moment, let me see what I can do to fix it

vchernyshov commented 2 years ago

@f-meloni it's simple but time consuming, bitbucket_cloud has different API response so it's not possible just to add new property to Danger with bitbucket_cloud, I had to modify several DTOs to make it work. Currently it's enough for me to test Danger-Kotlin, if it will cover all our needs we age going to add support of bitbucket_cloud by ourself and create PR to Danger-Kotlin

f-meloni commented 2 years ago

Yeah, Danger Swift has already that DSL built, so we might just try to copy it here https://github.com/danger/swift/blob/master/Sources/Danger/BitBucketCloud.swift

vchernyshov commented 2 years ago

Thanks, it will help me.

vchernyshov commented 2 years ago

@f-meloni I have checked cloud support for swift and looks like the models are outdated. I have extra question: is it possible to use pull request model inside plugin?