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.
我得到的输出为空。
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
优秀答案推荐
我是一名优秀的程序员,十分优秀!