How to Integrate Mayhem Into Your Jenkins Pipeline
Delivering secure, reliable APIs requires finding and fixing issues before shipping to production. That’s why Mayhem for API integrates easily into your CI/CD pipeline to automatically test your API for performance and security and validate it against your API specification.
With every build, Mayhem will run hundreds—or even thousands—of individual tests and deliver you triaged, actionable results that highlight defects and performance issues.
Mayhem offers several ways to integrate into your CI/CD. In this example, we’ll look at bringing Mayhem into a Jenkins pipeline using both Mayhem’s command line interface (CLI) as well as using Mayhem’s Docker image.
Configure Secrets
To start, you will need an API token to run Mayhem for API in your Jenkins pipeline:
- Create a Service Account token for your organization
- Add the newly created token as a "Secret text" entry in Jenkins Credentials named MAPI_TOKEN
Configure Your Pipeline
This will demonstrate how to run Mayhem for API against an API that is built and run in a Jenkins scripted pipeline. As a general rule, we recommend running Mayhem after any static scanning in your pipeline. These examples will start a local API instance to perform all testing against.
Run With Docker
In this scripted pipeline, after building your API, we use the Mayhem for API image on Docker Hub to run Mayhem as a containerized job and return results. Results are then collected in JUnit XML format.
Jenkins Integration
Running Mayhem for API in your Jenkins pipeline ensures you’re identifying security, reliability, and performance issues before shipping to production. Mayhem’s self-learning algorithms constantly expand coverage and provide an automated triage of results so you're not wading through hundreds of issues trying to prioritize. With Mayhem, every result found is actionable, helping you fix and ship software faster.
Add Mayhem to Your DevSecOps for Free.
Get a full-featured 30 day free trial.