I am struck with the requirements for a sprint now and unable to crack it and request you to help me with a bit complex requirement.
- I have a loop that outputs a list of JSON files.
for i in my_list; do echo $i; done
This list may vary between 15 and 30 based on the environment.
the $i
output looks something like this "apple.json
, boy.json
", etc.
- I now want the output of
$i
in the below curl command and keep on append to--form "actions[][file_path]=JSON_FILES/$SYNC_ENV/$i.json" \
and--form "actions[][content]=<$i.json" \
.
Kindly note there are no files to append and all this is dynamic by assigning to a variable
eg: my_ultimate_dynamic_command
${CURLPOST} --form "branch=default-branch" \
--form "commit_message=[ Syncing ]" \
--form "actions[][action]=update" \
--form "actions[][file_path]=JSON_FILES/$SYNC_ENV/$i.json" \
--form "actions[][content]=<$i.json" \
-H "PRIVATE-TOKEN:$TOKEN" "https://gitlab.myorg.com/api/v4/projects/$prid/repository/commits"
- expected output after the loop ends and echo of
$my_ultimate_dynamic_command
as below...
${CURLPOST} --form "branch=default-branch" \
--form "commit_message=[ Syncing ]" \
--form "actions[][action]=update" \
--form "actions[][file_path]=JSON_FILES/$SYNC_ENV/apple.json" \
--form "actions[][content]=<apple.json" \
--form "actions[][action]=update" \
--form "actions[][file_path]=JSON_FILES/$SYNC_ENV/boy.json" \
--form "actions[][content]=<boy.json" \
...and so on until $i is empty
-H "PRIVATE-TOKEN:$TOKEN" "https://gitlab.myorg.com/api/v4/projects/$prid/repository/commits"
- Finally, the dynamically generated variable should be executed as
eval $my_ultimate_dynamic_command
Appreciate it if someone could help me with this.