TravisCI Integration¶
In this guide we'll show you how to set up a TravisCI pipeline so that Mayhem can automatically test your code on every push.
You will need the following to run Mayhem in your TravisCI pipeline:
- Create a Mayhem API token.
- Add the newly created token as a "Secret Variable" in the pipeline's variables named
MAYHEM_TOKEN
Pipeline Configuration for Mayhem with TravisCI¶
Create a .travis.yml
file to configure a TravisCI pipeline to test your code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
Integrating Mayhem with TravisCI¶
Now that we've shown you the .travis.yml
file that you'll need to properly integrate Mayhem with TravisCI, let's walk through a working example.
Info
For this example we are forking the assets located at mcode-action-examples and integrating Mayhem into the TravisCI pipeline for the underlying targets.
To get the config working in TravisCI, you will have to first set up the Secret Variables. For this example, we've set the following variables:
MAYHEM_TOKEN
: Your user generated Mayhem API token.MAYHEM_URL
: The URL to the Mayhem server. Here we sethttps://app.mayhem.security
.GITHUB_USERNAME
: Your GitHub username.GITHUB_TOKEN
: Your GitHub access token.
In addition, for the above .travis.yml
configuration, we build and push our Docker image to the GitHub Container Registry. Therefore, make sure to set your project's visibility to Public
to allow Mayhem to pull from the GitHub Container Registry for the repository Docker image.
Once the above steps have been completed, you should be able to successfully execute a pipeline to have Mayhem test the underlying targets.