gpt4 book ai didi

Jenkins 使用 Groovy 读取 Jenkinsfile 中文件的特定行

转载 作者:行者123 更新时间:2023-12-03 23:14:04 31 4
gpt4 key购买 nike

我正在尝试使用 html 读取 Jenkins stageGroovy 文件的特定行,并将其内容保存到环境变量中。问题是, FilereadLines() 是不允许的。

我能够加载一个文件

env.WORKSPACE = pwd()
def file = readFile "${env.WORKSPACE}/file.html"

Provided in this answer

但是如何立即访问 n 行的内容?我正在使用 Jenkins 2.32

最佳答案

只是要在这里留下文档,但您也可以使用 readLines()。

def file = readFile location
def lines = file.readLines()

From this other question

关于Jenkins 使用 Groovy 读取 Jenkinsfile 中文件的特定行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43740474/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com