I'm trying to write a shell script which read variables from a file and replace that with the Environment variable define in GoCD.
Now the challenge i'm facing is i'm trying to use value of variable as parameter
Below is my script
#!/bin/bash
filename="keyword.txt"
while IFS="," read f1 f2 f3
do
f6="Env_var"
a="$($f6)"
echo $a
# echo "$f1" "$f3"
# sed -i s|$f1|$($f6)|g /var/lib/go-agent/pipelines/StormCluster-Deploy-2/"$f3".xml
done < "$filename"
Also in GoCD environment variable,i have given Env_var = 1234
Now here the script is giving output $Env_var
Where as i want that $Env_var value i.e 1234 define in GoCD as Environment variable should be the output
Kindly help!
I think the problem is not in GoCD, but in wrong parameter expansion. What you should probably do is:
You can read more about that in Shell Parameter Expansion section.