为什么jenkins管道内部具有“ readfile”的功能返回错误的类型?

发布于 2025-01-30 17:27:57 字数 1072 浏览 1 评论 0原文

为什么readfile jenkins管道中的功能返回错误的类型?

@NonCPS
def getChanged(changeTrackingOutput, ruleName, ciTags) {
  echo """CI Tags: ${ciTags}"""

  if (ciTags.contains('build-all')) {
    return true
  }
  // Check output of the change detection.
  def ys = new Yaml()
  def fileData = readFile(changeTrackingOutput)
  echo """File: ${fileData.getClass()}, ${fileData}"""

  def res = ys.load(fileData)
  echo """RRes: ${res.getClass()}, ${res}"""

  def changed = res['changed'].contains(ruleName)
  echo """Type: ${changed.getClass()}, ${changed}"""

  ys = null  // Null everything: https://blog.thesparktree.com/you-dont-know-jenkins-part-3
  res = null
  fileData = null

  return 

当我在脚本步骤中使用此功能时。 我看不到readfile之后的任何输出(。有些东西真的很酸甜,在我看来,函数get feathanged以某种方式返回readfile。类型I是String而不是布尔它应该

很难在这里看到什么

。 ://i.sstatic.net/dolhx.png“ rel =” nofollow noreferrer“>

之后什么都没有。

Why does a function with readFile inside Jenkins Pipeline returns wrong type?

@NonCPS
def getChanged(changeTrackingOutput, ruleName, ciTags) {
  echo """CI Tags: ${ciTags}"""

  if (ciTags.contains('build-all')) {
    return true
  }
  // Check output of the change detection.
  def ys = new Yaml()
  def fileData = readFile(changeTrackingOutput)
  echo """File: ${fileData.getClass()}, ${fileData}"""

  def res = ys.load(fileData)
  echo """RRes: ${res.getClass()}, ${res}"""

  def changed = res['changed'].contains(ruleName)
  echo """Type: ${changed.getClass()}, ${changed}"""

  ys = null  // Null everything: https://blog.thesparktree.com/you-dont-know-jenkins-part-3
  res = null
  fileData = null

  return 

When I use this function inside a script step.
I cannot see any output after readFile(. Something is really fishy, it appears to me that the function getChanged returns somehow after readFile. Also outside the type I get is String and not boolean which it should be.

Its really hard to see whats going on here. Also in OpenBlueOcean I see:

enter image description here

with nothing after that.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文