in teamcity-rest-client-impl/src/main/kotlin/org/jetbrains/teamcity/rest/coroutines/implementation.kt [2169:2182]
override suspend fun findArtifact(pattern: String, parentPath: String, recursive: Boolean): BuildArtifact {
val list = getArtifacts(parentPath, recursive)
val regexp = convertToJavaRegexp(pattern)
val result = list.filter { regexp.matches(it.name) }
if (result.isEmpty()) {
val available = list.joinToString(",") { it.name }
throw TeamCityQueryException("Artifact $pattern not found in build ${getBuildNumber()}. Available artifacts: $available.")
}
if (result.size > 1) {
val names = result.joinToString(",") { it.name }
throw TeamCityQueryException("Several artifacts matching $pattern are found in build ${getBuildNumber()}: $names.")
}
return result.first()
}