Shell script with a for loop and an “array”
0
votes
2
answers
2459
views
How can I use this shell script with for loop and an array.
I would like to call create condition for quality gate creation of sonarqube with a for loop. Example:
#!/bin/bash --login
echo "Creating SonarQube Gateway Condition"
QG_ID=$(cat qualitygate.json | jq -r ".id")
Gateway="curl -u ${USERNAME}:${PASSWORD} -k -X POST "${SONAR_HOST_URL}/api/qualitygates/create_condition?"
declare -a gateMetrics=("gateId=$QG_ID&metric=coverage&op=LT&error=80\"" "gateId=$QG_ID&metric=duplicated_lines_density&op=GT&error=10\"")
for val in "${gateMetrics[@]}"
do
echo $Gateway$val
done
I want the output as below after running above command
curl -u ${USERNAME}:${PASSWORD} -k -X POST "${SONAR_HOST_URL}/api/qualitygates/create_condition?gateId=$QG_ID&metric=coverage&op=LT&error=80"
Asked by user1628
(11 rep)
Jan 25, 2021, 08:09 AM
Last activity: Dec 17, 2023, 07:03 AM
Last activity: Dec 17, 2023, 07:03 AM