如何将错误消息从批处理文件传递到团队城市

时间:2019-07-01 20:20:46

标签: batch-file teamcity

我正在团队城市构建步骤中执行批处理文件。批处理文件具有此代码。

enum FetchError : Error {
  case unknownKey
}

protocol FetchKey {
  associatedtype ValueType

  func get() -> ValueType
}

struct GetNameKey: FetchKey {
  func get() -> String {  // This line establishes the getName → String mapping
    return "Johnny Appleseed"
  }
}

struct GetWidthKey: FetchKey {
  func get() -> Double {  // This line establishes the getWidth → Double mapping
    return 25.0
  }
}

// This function signature means: “If you give fetchValue a key, it
// will give you a result _with the appropriate type_ for that key”
//
func fetchValue<K: FetchKey>(_ key: K) -> Result<K.ValueType, FetchError> {
  // The return type here is Result<K.ValueType, FetchError>, but
  // now Swift has enough into to infer it!
  return Result.success(key.get())
}

// This now works without type inference:
let r0 = fetchValue(GetNameKey())
print(r0)

// And this now (correctly) fails to compile:
// let r1: Result<Double, FetchError> = fetchValue(GetNameKey())

%errorlevel%仅提供错误级别。如何获取错误消息,以便将其传递给团队城市消息服务。

1 个答案:

答案 0 :(得分:0)

您应该在双引号内传递
echo "##teamcity[message text='failed' errorDetails='' status='ERROR']"

如果要将错误信息添加到构建问题中,请使用以下命令:
echo "##teamcity[buildProblem description='Some conditions return an error' status='ERROR']"