Hi KodeKloud ,
I’m working on enhancing my Jenkins Pipeline to include code quality checks, testing, and code coverage reporting. I’ve added a stage for code coverage, but when I run the pipeline, I get this warning:
“Code Coverage: No steps. This stage has no steps.
Chapter Context:


my Jenkinsfile:
pipeline {
agent any
tools {
nodejs 'nodeJS 20.19.2'
}
environment {
MONGO_URI = “mongodb+srv://superclister.d83jj.mongodb.net/superData”
}
options {
disableResume()
disableConcurrentBuilds abortPrevious: true
}
stages {
stage('Installing Dependencies') {
options { timestamps() }
steps {
sh 'npm install --no-audit'
}
}
stage('Dependency scanning') {
parallel {
stage('NPM Dependency Audit') {
steps {
sh 'npm audit --audit-level=critical || true'
}
}
stage('OWASP Dependency Check') {
steps {
dependencyCheck additionalArguments: '''--scan . \
--project "solar-system" \
--format ALL \
--out dependency-check-report \
--prettyPrint \
--failOnCVSS 7 \
--enableExperimental \
--suppression my-suppression.xml''',
odcInstallation: 'OWASP-Depcheck-12'
dependencyCheckPublisher(
failedTotalCritical: 1,
pattern: 'dependency-check-report.xml',
stopBuild: true
)
junit allowEmptyResults: true, testResults: 'dependency-check-junit.xml'
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: './',
reportFiles: 'dependency-check-jenkins.html',
reportName: 'Dependency Check HTML Report',
useWrapperFileDirectly: true
])
}
}
}
}
stage('Unit Testing') {
options { retry(2) }
steps {
withCredentials([usernamePassword(credentialsId: 'mongo-db-cred ', passwordVariable: 'MONGO_PASSWORD', usernameVariable: 'MONGO_USERNAME')]) {
}
junit allowEmptyResults: true, testResults: 'test-results.xml' }
}
}
}
stage('Code Coverage') {
steps {
withCredentials([usernamePassword(credentialsId: 'mongo-db-cred', passwordVariable: 'MONGO_PASSWORD', usernameVariable: 'MONGO_USERNAME')]) {
catchError(message: 'Oops! it will be fixed in future releases', stageResult: 'UNSTABLE') {
sh 'npm run coverage'
}
}
publishHTML([
allowMissing: true,
alwaysLinkToLastBuild: true,
keepAll: true,
reportDir: 'coverage/lcov-report',
reportFiles: 'index.html',
reportName: 'Code Coverage Report'
])
}
}