danger / swift

⚠️ Stop saying "you forgot to …" in code review

Home Page:https://danger.systems/swift/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

after upgrade bitbucket server to version 8.9.0, keyNotFound 'tasks'

jfernand21 opened this issue · comments

Report

danger executions fail, after upgrate bitbucket server to version 8.9.0

What did you do?

We are running whitout any issue in our jenkins server with bitbucket server version 7. After the upgrade of the bitbucket server to version 8.9, the danger stage in ours pipelines stop working

ℹ we run this command
DEBUG=* danger-swift ci --cwd ../

What did you expect to happen?

We are expecting that the command execution happen successfully and comment the PR associated

ℹ Please replace this with what you expected to happen.
Running your Dangerfile without it crashing.

What happened instead?

The execution fail with a error parse the bitbucket server informations of the PR

ℹ The error returning is this:

Decoding the DSL into Swift types
 ERROR: Failed to parse JSON: keyNotFound(CodingKeys(stringValue: "tasks", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "danger", intValue: nil), CodingKeys(stringValue: "bitbucket_server", intValue: nil), CodingKeys(stringValue: "comments", intValue: nil), _JSONKey(stringValue: "Index 6", intValue: 6), CodingKeys(stringValue: "comment", intValue: nil), CodingKeys(stringValue: "comments", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0)], debugDescription: "No value associated with key CodingKeys(stringValue: \"tasks\", intValue: nil) (\"tasks\").", underlyingError: nil))

Your Environment

  • Which CI are you running on?
    Jenkins 2.289.3
  • Are you running the latest version of Danger?
    Danger Swift runner (v3.17.1)
  • What is your Dangerfile?
import Danger
import DangerSwiftCoverage // package: https://github.com/f-meloni/danger-swift-coverage.git
import DangerXCodeSummary // package: https://github.com/f-meloni/danger-swift-xcodesummary.git

let danger = Danger()
let editedFiles = danger.git.modifiedFiles + danger.git.createdFiles
let swiftFiles = editedFiles.filter { $0.fileType == .swift }
let swiftFilesForLint = editedFiles.filter { $0.contains("iOSUIComponents/Classes/") }

if editedFiles.count - danger.git.deletedFiles.count > 300 {
  warn("Big PR, try to keep changes smaller if you can")
}

let swiftFilesWithCopyright = danger.git.createdFiles.filter {
  $0.fileType == .swift
    && danger.utils.readFile($0).contains("//  Created by")
}

if !swiftFilesWithCopyright.isEmpty {
  let files = swiftFilesWithCopyright.joined(separator: ", ")
  warn("In Danger we don't include copyright headers, found them in: \(files)")
}

func filesWithUnauthorizedAbbreviations(files: [File]) {
  let unAuthorizedAbbreviations = ["VM.swift", "VS.swift", "VD.swift", "VC.swift"]
  let detectedFiles = files.filter { unAuthorizedAbbreviations.contains(where: $0.name.contains) }
  for file in detectedFiles {
    fail("Unauthorized Abbreviation in \(file)")
  }
}
filesWithUnauthorizedAbbreviations(files: swiftFiles)

let hasNotDescription = danger.bitbucketServer.pullRequest.description ?? ""
if hasNotDescription.isEmpty {
  message("Please, provide a PR description.")
}

SwiftLint.lint(.files(swiftFilesForLint),
               configFile: ".swiftlint.yml",
               swiftlintPath: "./Demo/Pods/SwiftLint/swiftlint")
Coverage.xcodeBuildCoverage(.derivedDataFolder("./DerivedData"), minimumCoverage: 80)

Hi, I already generate a PR to solve this, changing the "Tasks" array value to optional.

#595