Learn to streamline an existing Jenkins Pipeline for advanced demonstrations by refactoring the Jenkinsfile to include only essential stages and organized reports.
In this lesson, you will learn how to streamline an existing Jenkins Pipeline in preparation for advanced demonstrations. We assume you’re already familiar with Jenkins Pipeline basics. By the end, you’ll have a lean Jenkinsfile with only essential stages, organized Trivy reports, and a dedicated branch for future enhancements.
First, navigate to your Jenkins dashboard. We’re using a Git Organization Folder job configured with two repositories. In the solar-system repo, we’ve been working on the feature/enabling-flag branch.
Inside the solar-system organization folder, multiple branches are listed. Last time, our focus was feature/enabling-flag.
On the Git hosting side, the repository belongs to the dasher-org organization and currently has three branches, including feature/enabling-slack.
Here’s the code view on the feature/enabling-slack branch, showing recent commits and file structure.
Switch to your local solar-system directory and check out the feature/enabling-slack branch:
Copy
cd solar-systemgit checkout feature/enabling-slack
Open Jenkinsfile in your code editor. It contains roughly 19 stages including notifications, dependency checks, testing, Docker builds, deployments, and more. For our advanced demos, we only need these stages:
trivy image … + trivy convert … (see detailed snippet)
We’re removing all other stages (e.g., OWASP Dependency Check, deployment) by commenting them out. This keeps the pipeline focused and faster to iterate.
Open Blue Ocean or the classic Jenkins UI to inspect your build stages. You should see only the simplified stages in sequence.
The Installing Dependencies stage may fail because of the --no-audit flag. This is intentional. Subsequent Slack notifications will still provide build status updates in your channel.
We’ll cover Trivy caching and handling rate limits in future lessons.Congratulations! Your feature/advanced-demo branch now has a clean, focused Jenkins pipeline ready for advanced demos.