danger/kotlin

NullPointerException bitBucketServer

vchernyshov opened this issue · 7 comments

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?

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

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

@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

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

@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

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

Thanks, it will help me.

@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?