# checking if the project exists
- export is_project_existing=$(curl https://{$SONAR_TOKEN}@sonarcloud.io/api/projects/search?organization=myorganization | grep -w $CI_PROJECT_NAME)
- |
if [[ ! -z $is_project_existing ]]; then
echo "Project exists on sonarcloud, proceeding to analysis"
else
# creating new project
curl -X POST https://{$SONAR_TOKEN}@sonarcloud.io/api/projects/create -d "name=$CI_PROJECT_NAME&project=myorganization_$CI_PROJECT_NAME&organization=myorganization"
fi