- Solar System CI Pipeline
- CI Pipeline (poll SCM)


- Small Node.js application.
- Key files:
Dockerfile— image buildJenkinsfile— declarative pipeline used by Jenkinsapp.js,app-test.js— application and unit testspackage.json/package-lock.json— dependencies and scripts
Avoid placing secrets in
Dockerfile via ENV for production images. Store sensitive values in a secrets manager or inject them at runtime (e.g., via Jenkins credentials or container runtime secrets).Jenkinsfile defines an end-to-end CI pipeline that runs inside Docker agents and uses Jenkins tools/credentials. Main stages include installing dependencies, dependency scanning, unit testing, code coverage, building & publishing a Docker image, and a Trivy image scan.
Representative (cleaned) Jenkinsfile excerpt:
| Stage | Purpose | Key commands | Artifacts |
|---|---|---|---|
| Installing Dependencies | Install project dependencies | npm install --no-audit | node_modules/ (workspace) |
| NPM Dependency Audit | Quick audit for npm vulnerabilities | npm audit --audit-level=critical | audit output |
| OWASP Dependency-Check | Comprehensive SBOM-based scan | dependencyCheck plugin | dependency-check-report.xml/html/json |
| Unit Testing | Run unit tests | npm test | JUnit XML (optional) |
| Code Coverage | Generate coverage metrics | npm run coverage | coverage reports (lcov, cobertura) |
| Build & Publish Image | Build Docker image & push to registry | docker build, docker push | Docker image on Docker Hub |
| Trivy Vulnerability Scanner | Scan container image for vulnerabilities | trivy image + trivy convert | Trivy JSON/HTML |
- Node.js tool is managed by Jenkins and the pipeline runs Node steps inside Docker agents.
- Credentials for MongoDB, Docker Hub, and NVD API key are stored in Jenkins and referenced via
credentials()and plugin parameters. - Dependency-Check and Trivy produce XML/HTML/JSON reports; the repository includes commented
publishHTML/junitlines — uncomment to publish artifacts in Jenkins.
Obtain an NVD API key and store it in Jenkins credentials. Using the API key reduces the time Dependency-Check spends downloading the NVD feed and improves scan reliability.

- Request the API key at:
https://nvd.nist.gov/developers/request-an-api-key - After receiving the API key, create a Jenkins credential (Secret text) and reference that credential id in the Dependency-Check plugin configuration (
nvdCredentialsId).

- Installing Dependencies stage runs
npm installinside a Docker container. - Dependency Scanning runs:
npm audit --audit-level=critical- OWASP Dependency-Check via the plugin which writes XML/HTML/JSON/SARIF/JUnit reports into the workspace.
dependencyCheckPublisher step will fail the build. In this project the publisher was initially set to fail on medium/low severities, which caused builds to fail. I adjusted the publisher to fail only on critical vulnerabilities by setting failedTotalCritical: 1 and removing medium/low thresholds.
Dependency-Check update output (first run example):
formidable:2.1.2 CVE-2025-46653). Because the publisher was originally configured to stop builds on medium/low findings, the pipeline failed until thresholds were relaxed.

- Unit Testing runs
npm testinside the Docker agent and usesretry(2)to handle transient failures. - Code Coverage runs
npm run coverage(nyc). Coverage did not meet the global threshold in this run (~79% vs expected 90%), so the coverage stage failed its threshold check. Because coverage was wrapped withcatchError(buildResult: 'SUCCESS', stageResult: 'UNSTABLE', ...), the overall build remained successful while the coverage stage was marked unstable.

publishHTML to surface results in Jenkins.
Wrapping up
- Both pipelines use the same
Jenkinsfilefromjenkins-demo-org/solar-system; the poll-SCM job adds a cron trigger. - OWASP Dependency-Check and Trivy are integrated for dependency and container-image vulnerability checks. Provide an NVD API key to speed Dependency-Check database updates.
- Tests and coverage execute inside Docker agents. Use
catchErrorin the coverage stage to surface coverage issues without failing the entire build. - Artifacts produced (Dependency-Check HTML, Trivy HTML, JUnit XML, coverage reports) are present but publishing calls are commented out — uncomment
publishHTMLorjunitlines in the Jenkinsfile to show these reports in Jenkins. - Next steps: migrate this pipeline to GitHub Actions and enable publishing of test, coverage, and security reports from the CI workflow. See GitHub Actions course for guidance.