Scan your staging site in Jenkins after each deploy, fail the build on what you choose, and see each test on the build's Test Result page.
Before you start
- A verified domain for the site.
- An API key. Use a team key in CI: see Keys for CI.
- Node 20.19 or later on the agent, and the JUnit plugin for the test results.
Add the stage
Jenkinsfile
stage('ValiqAI scan') {
environment {
VALIQAI_API_KEY = credentials('valiqai-api-key')
STAGING_URL = 'https://staging.example.com'
}
steps {
sh 'npx -y @valiqai/cli scan "$STAGING_URL" --fail-on blocker --output valiqai-junit.xml'
}
post {
always {
junit 'valiqai-junit.xml'
}
}
}The key goes in: Manage Jenkins › Credentials, as secret text "valiqai-api-key". Results show in: the build's Test Result page (needs the JUnit plugin).
Deploy, then scan
Code
pipeline {
agent any
stages {
stage('Deploy') {
steps {
sh './scripts/deploy-staging.sh'
}
}
stage('ValiqAI scan') {
environment {
VALIQAI_API_KEY = credentials('valiqai-api-key')
STAGING_URL = 'https://staging.example.com'
}
steps {
sh 'npx -y @valiqai/cli scan "$STAGING_URL" --fail-on blocker --output valiqai-junit.xml'
}
post {
always {
junit 'valiqai-junit.xml'
}
}
}
}
}What you'll see
- The build's Test Result page: each test the scan ran. A test fails when it found an open problem at
--fail-onor above. - The console output: progress, the summary, and a link to the scan.
- The scan's page in ValiqAI says Jenkins, with the branch and commit when Jenkins provides them, linking back to the build.