Sonar project bulk deletion with bash shell to call Sonar web API
2017-02-19 16:23
330 查看
#!/bin/bash
env_name=$1
admin_name=$2
project_id=(111 222 333 4444)
sonar_url_prod=SONAR_prod_URL/api/projects/destroy?id=
sonar_url_uat=SONAR_uat_URL/api/projects/destroy?id=
if [ $env_name == "uat" ]
then
echo "Clean up uat projects"
elif [ $env_name == "prod" ]
then
echo
echo "Clean production projects"
fi
echo - n "Enter password for user sonar admin: " stty -echo; read admin_pwd; stty echo; echo
for ((i=0;i<${#project_id[@]};i++))
do
if [ $env_name == "uat" ]
then
echo "project id is "+${project_id[i]} >> output.log
echo ${date} >> output.log
result=$(curl -k -x POST $sonar_url_uat+${project_id[i]} --user $admin_user:$admin_pwd)
echo $result >> output.log
elif [ $env_name == "prod" ]
then
echo "project id is "+${project_id[i]} >> output.log
echo ${date} >> output.log
result=$(curl -k -x POST $sonar_url_prod+${project_id[i]} --user $admin_user:$admin_pwd)
echo $result >> output.log
fi
done
env_name=$1
admin_name=$2
project_id=(111 222 333 4444)
sonar_url_prod=SONAR_prod_URL/api/projects/destroy?id=
sonar_url_uat=SONAR_uat_URL/api/projects/destroy?id=
if [ $env_name == "uat" ]
then
echo "Clean up uat projects"
elif [ $env_name == "prod" ]
then
echo
echo "Clean production projects"
fi
echo - n "Enter password for user sonar admin: " stty -echo; read admin_pwd; stty echo; echo
for ((i=0;i<${#project_id[@]};i++))
do
if [ $env_name == "uat" ]
then
echo "project id is "+${project_id[i]} >> output.log
echo ${date} >> output.log
result=$(curl -k -x POST $sonar_url_uat+${project_id[i]} --user $admin_user:$admin_pwd)
echo $result >> output.log
elif [ $env_name == "prod" ]
then
echo "project id is "+${project_id[i]} >> output.log
echo ${date} >> output.log
result=$(curl -k -x POST $sonar_url_prod+${project_id[i]} --user $admin_user:$admin_pwd)
echo $result >> output.log
fi
done
相关文章推荐
- Migrating from VS 2005 to VS 2008 with Microsoft.VisualStudio.Shell references (译)
- Bash tip: How to stop many processes in with a small script
- SharePoint Project Deployment Fails With Error "Failed to extract the cab file in the solution"
- How to Cross Compile the Bash shell for Android 1.5 (为Android平台编译Bash shell)
- An Introduction to Bash Shell Programming in Linux
- How to solve the problem "A project with an Output Type of Class Library cannot be started directly "
- pacparser - A library to make your web software pac (proxy auto-config) files intelligent. Comes with much useful pactester tool now. - Google Project Hosting
- error C3395: __declspec(dllexport) cannot be applied to a function with the __clrcall calling conv
- Reverse Shell with Bash
- 运行project提示conversion to dalvik format failed with error 原因
- Migrating from VS 2005 to VS 2008 with Microsoft.VisualStudio.Shell references (译)
- How to control the jobs with shell?
- The module ... was loaded but the call to DllRegisterServer failed with error code 0x80070005
- "Cannot allocate memory" OutofMemory when call Ant to build Polish project in Tomcat
- How to construct a Android project with Google Map APIs
- An error occurred during the execution of xp_cmdshell. A call to 'LogonUserW' failed with error code: '1385'
- Usage sample of unix signal to handle function call with a timeout value.
- Ten things to do with IIS(From CodeProject website)
- Project is missing required source folder:’gen’和conversion to Dalvik format failed with error 1解决方案
- How to setup and configure Sonar for Groovy projects