How to change gitlab commit status

stages:

  • analyze
    sonar_analyze:
    stage: analyze
    before_script:
    • echo “before_script”
      script:
    • sh /opt/gitlab-ci/sonar_analyze.sh
    • echo $?
      allow_failure: false
      after_script:
    • echo “after_script”

As the above code, get ? value, the question is : How do you go from the ?'s value to change gitlab pipeline to failture