在詹金斯声明管道中使用ReadyAml的正确方法是什么

发布于 2025-01-23 12:44:59 字数 79 浏览 2 评论 0原文

我看到了如何从脚本詹金斯读取yaml文件的示例。我正在寻找一个示例,说明如何正确阅读jenkins声明管道中的yaml(使用readyaml?)

I saw examples of how to read a YAML file from a scripted Jenkins. I am looking for an example of how to properly read YAML (using readYaml?) in Jenkins declarative pipeline

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

忆梦 2025-01-30 12:44:59

文档: https://www.jenkins.io/doc/pipeline/pipeline/steps/pipeline-utility-steps/#readyaml-wreadyaml-read-yaml-read-yaml-from-from-from-from-from-in-the-work-work-work-workspace-or-or-text

在一行中,您可以使用readyAml这样:

def yaml = readYaml text: yourYamlContent

您应该有一个可以从:

env.SOURCE_BRANCH = yaml.source.branch.name

The documentation: https://www.jenkins.io/doc/pipeline/steps/pipeline-utility-steps/#readyaml-read-yaml-from-files-in-the-workspace-or-text

In a single line, you can use readYaml like this:

def yaml = readYaml text: yourYamlContent

and you should have a yaml object you can extract data from, such as:

env.SOURCE_BRANCH = yaml.source.branch.name
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文