gpt4 book ai didi

Parse values in Groovy script from yml file(从YML文件中解析Groovy脚本中的值)

转载 作者:bug小助手 更新时间:2023-10-25 17:24:46 24 4
gpt4 key购买 nike



I have the following yml output from running a shell command:

运行一个外壳命令后,我得到了以下YML输出:


repositories:
- createdAt: '2023-09-07T22:30:50+00:00'
encryptionConfiguration:
encryptionType: AES256
imageScanningConfiguration:
scanOnPush: false
imageTagMutability: MUTABLE
registryId: '12344'
repositoryArn: arn:aws:ecr:us-east-1:12344
repositoryName: test-registry
repositoryUri: 12344

I use this groovy script to get the value:

我使用这个Groovy脚本来获取值:


def profile = "ecr"
def region = "us-east-1"
def cmd_output = "aws ecr describe-repositories --profile $profile --region $region --output yaml".execute()
def awk_cmd_output = cmd_output | ['awk', '/repositoryName:/ {print $2}'].execute()
def repo_names = awk_cmd_output.text.tokenize().reverse()
return repo_names

But for some reason the value test-registry is not parsed properly.

但是由于某些原因,值test-Registry没有被正确地解析。


Do you know how I can fix this?

你知道我怎么才能解决这个问题吗?


更多回答

"is not parsed properly" How is it currently parsed?

“未正确解析”它当前是如何解析的?

I get empty output.

我得到的输出为空。

You did not get an error like here: onecompiler.com/groovy/3zm5ma4k8 ? (I am new too Groovy, so ... )

您没有收到如下错误:onecompiler.com/groovy/3zm5ma4k8?(我也是新手,所以...)

This groovy script is used into jenkins plugin Active Choices. I get empty dropdown.

这个Groovy脚本被用于Jenkins插件Active Choices中。我得到的下拉列表是空的。

new YamlSlurper().parseText(cmd_output).repositories[0].repositoryName

新YamlSlurper().parseText(cmd_output).repositories[0].repositoryName

优秀答案推荐
更多回答

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