I have a gitlab-ci integration that require a sonar analysis and if the quality gates pass, to build a docker image.
Is this possible using gitlab-ci ?
You should try the Sonar Build Breaker plugin. It enables returning non-zero which would break the Gitlab CI Runner's build, not performing the next step (building the Docker image).
Create a .gitlab-ci.yml file in the root of your project:
stages:
- sonarqube
- docker_build
image: maven:3-jdk-8
sonarqube:
stage: sonarqube
script:
- # sonarqube running command (plugin installed), mvn blabla
docker_build
stage: docker_build
script:
- docker build .
A commit to Gitlab will run the sonarqube stage and continue with docker_build only if sonarqube passes the Quality Gate.