sonarcloud-project-organization: ORGANIZATION
     sonarcloud-api-token: TOKEN
     scan-dev-branch: false
+    sonarcloud-qualitygate-wait: false
 
 - project:
     name: example-sonarcloud-with-prescan-script
     sonar-prescan-script: |
       echo "Run script at start of job."
     scan-dev-branch: false
+    sonarcloud-qualitygate-wait: false
 
 - project:
     name: example-sonarcloud-verify
     sonarcloud-project-organization: ORGANIZATION
     sonarcloud-api-token: TOKEN
     scan-dev-branch: true
+    sonarcloud-qualitygate-wait: true
 
     :sonarcloud-project-organization: SonarCloud project organization.
     :sonarcloud-api-token: SonarCloud API Token.
     :sonarcloud-java-version: Version of Java to run the Sonar scan. (default: openjdk11)
+    :sonarcloud-qualitygate-wait: SonarCloud flag that forces the analysis step to
+        wait for the quality gate result. (default: false)
 
 lf-maven-build
 --------------
         (default: '')
     :sonarcloud-api-token: SonarCloud API Token. (default: '')
     :sonarcloud-java-version: Version of Java to use for the Sonar scan. (default: openjdk11)
+    :sonarcloud-qualitygate-wait: SonarCloud flag that forces the analysis step to
+        wait for the quality gate result. (default: false)
     :stream: Keyword that represents a release code-name.
         Often the same as the branch. (default: master)
     :submodule-recursive: Whether to checkout submodules recursively.
 
     sonarcloud-project-key: ""
     sonarcloud-project-organization: ""
     sonarcloud-api-token: ""
+    sonarcloud-qualitygate-wait: false
     # SonarCloud scan using jdk8 will become deprecated by Oct, 2020
     # Projects not compatible with jdk11 can set java-version to something else
     sonarcloud-java-version: openjdk11
                 sonarcloud-project-organization: "{sonarcloud-project-organization}"
                 sonarcloud-api-token: "{sonarcloud-api-token}"
                 sonarcloud-java-version: "{sonarcloud-java-version}"
+                sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
                 scan-dev-branch: "{scan-dev-branch}"
       # With SonarQube
       - conditional-step:
                 sonarcloud-project-organization: "{sonarcloud-project-organization}"
                 sonarcloud-api-token: "{sonarcloud-api-token}"
                 sonarcloud-java-version: "{sonarcloud-java-version}"
+                sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
                 scan-dev-branch: "{scan-dev-branch}"
       # With SonarQube
       - conditional-step:
             API_TOKEN={sonarcloud-api-token}
             SONARCLOUD_JAVA_VERSION={sonarcloud-java-version}
             SCAN_DEV_BRANCH={scan-dev-branch}
+            SONARCLOUD_QUALITYGATE_WAIT={sonarcloud-qualitygate-wait}
       - lf-provide-maven-settings:
           global-settings-file: global-settings
           settings-file: "{mvn-settings}"
 
     sonarcloud: true
     scan-dev-branch: true
+    sonarcloud-qualitygate-wait: false
 
     gerrit_sonar_triggers:
       - patchset-created-event:
 
     sonarcloud-project-key: ""
     sonarcloud-project-organization: ""
     sonarcloud-api-token: ""
+    sonarcloud-qualitygate-wait: false
     # SonarCloud scan using jdk8 will become deprecated by Oct, 2020
     # Projects not compatible with jdk11 can set java-version to something else
     sonarcloud-java-version: openjdk11
                 sonarcloud-project-organization: "{sonarcloud-project-organization}"
                 sonarcloud-api-token: "{sonarcloud-api-token}"
                 sonarcloud-java-version: "{sonarcloud-java-version}"
+                sonarcloud-qualitygate-wait: "{sonarcloud-qualitygate-wait}"
                 scan-dev-branch: "{scan-dev-branch}"
       # With SonarQube
       - conditional-step:
 
--- /dev/null
+---
+features:
+  - |
+    Add support for wait flag on SonarCloud quality gates, this way jobs
+    won't finish until the quality gate reports back the result during
+    the analysis step, which will fail anytime the quality gate fails.
 
         # shellcheck disable=SC2236
         if [ ! -z ${GERRIT_CHANGE_NUMBER+x} ]; then
             GERRIT_SHORT_LIVED_BRANCH=${GERRIT_CHANGE_NUMBER}-${GERRIT_PATCHSET_NUMBER}
+            lowercase_SONARCLOUD_QUALITYGATE_WAIT=$(echo "$SONARCLOUD_QUALITYGATE_WAIT" | tr '[:upper:]' '[:lower:]')
             params+=("-Dsonar.analysis.gerritProjectName=$PROJECT")
             params+=("-Dsonar.branch.target=$GERRIT_BRANCH")
             params+=("-Dsonar.branch.name=$GERRIT_SHORT_LIVED_BRANCH")
+            params+=("-Dsonar.qualitygate.wait=$lowercase_SONARCLOUD_QUALITYGATE_WAIT")
         fi
     fi
 fi