Sample Header Ad - 728x90

Replace value in yaml file using yq

1 vote
2 answers
6962 views
I am using yq version 4.34.1 in powershell. I try to replace the value of .spec.source.targetRevision in target.yaml with the newer value from a variable $newTargetRevision. So, what I am doing now is as follows. $newTargetRevision = "v1.1.1-1" yq -i '.spec.source.targetRevision = "$newTargetRevision"' target.yaml What I have got is as follows. spec: source: targetRevision: &default $newTargetRevision I expect to get:- spec: source: targetRevision: &default v1.1.1-1 I also tried removing double quotes from $newTargetRevision as follows, but the value in the yaml file is not updated at all. yq -i '.spec.source.targetRevision = $newTargetRevision' target.yaml I try many things but without success. Can you please suggest? Thanks
Asked by Rexagon (9 rep)
Feb 29, 2024, 03:33 PM
Last activity: Aug 22, 2024, 10:01 PM