Skip to main content
Bumped by Community user
it's not sh. Either bash or stay generic with shell
Source Link
Chris Davies
  • 128.4k
  • 16
  • 179
  • 324

How can I use this shshell 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"

How can I use this sh 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"

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"
Bumped by Community user
Bumped by Community user
formatting: remove rough newline, paragraphs, and indentation
Source Link
ctrl-alt-delor
  • 28.8k
  • 11
  • 67
  • 114

How can I use this sh 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"

How can I use this sh 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"

How can I use this sh 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"
deleted 2 characters in body
Source Link
muru
  • 78.4k
  • 16
  • 214
  • 320

How can I use this sh script with for loop and an arrayarray. 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"

How can I use this sh 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"

How can I use this sh 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"
added 76 characters in body
Source Link
muru
  • 78.4k
  • 16
  • 214
  • 320
Loading
Source Link
Loading