Shipping AI reliably with CI/CD and quality gates
AI changes deserve the same rigor as any production software. This is the pipeline that made every release safe and repeatable.
Why AI needs the same rigor as software
An AI service is still software: it can regress, leak bugs, or ship insecure code. Without automated checks, a small change quietly breaks recommendations or a deployment. A pipeline with gates turns "it worked on my machine" into a release you can trust.
The Jenkins pipeline, stage by stage
Each commit runs a fixed sequence: build and unit tests, static analysis, a quality gate, functional tests, a versioned Docker image, then deploy to the registry and cloud. Production deploys only from main, only after every stage passes.
Blocking bad code with a SonarQube quality gate
SonarQube analyses each build and a quality gate enforces hard rules: zero new bugs and vulnerabilities, security hotspots reviewed, coverage on new code above target, low duplication. If the gate fails, the pipeline stops.
Functional testing with Selenium
Selenium drives a real browser through the key journeys — searching for a "red summer dress" and confirming relevant recommendations appear. These end-to-end tests catch breakages unit tests miss, on the paths customers actually use.
Key decision: the release gate
Every change runs the same gates; a release only ships when each one passes.
Each commit runs in order: build and unit tests, then SonarQube analysis, then the quality gate.
Quality gate passed?
- Nothe pipeline stops, nothing ships
- Yesrun the Selenium functional tests, then check the branch
On the main branch?
- Nobuild the image only, no deploy
- Yespush the image and deploy to Azure
On top of those rules, the gate also requires A-grade maintainability, reliability and security before a release can pass.
More technical detail
// Jenkinsfile (essential stages)
stage('Build & test') { steps { sh 'mvn clean verify' } }
stage('SonarQube') { steps { withSonarQubeEnv('Sonar') { sh 'mvn sonar:sonar' } } }
stage('Quality Gate') {
steps { timeout(time: 10, unit: 'MINUTES') { script {
if (waitForQualityGate().status != 'OK') error 'Quality gate failed'
} } }
}
stage('Deploy') { when { branch 'main' }
steps { sh 'az webapp config container set ...' } }
Back to: The full case study