APIF-Auto, a command line tool that supports automated API Fortress test execution is an ideal tool for executing API Fortress tests in a Jenkins workflow.
The pipeline script below serves as a template for creating a stage in your Jenkins Pipeline for testing your APIs with API Fortress. If you’d like to take a look at the documentation for APIF-Auto, click here. It’s important to note that this is an example of a Jenkins Pipeline. Experienced Jenkins users are free to configure their workflow as best suits their needs.
pipeline{
agent any
stages {
stage('Execute API Fortress Tests') {
steps {
sh 'mkdir -p apifortress-reports'
sh 'python /Path/to/apif-Auto/directory/apif-run.py run-all demo -S -f junit -o apifortress-reports/apif.xml'
}
post {
always {
junit "apifortress-reports/"
}
}
}
}
}
sh ‘mkdir -p apifortress-reports’
Let’s break down what’s going on here! First, we’re telling jenkins to create a new directory called ‘apifortress-reports.’ You can name this directory whatever you’d like, but there are a couple of important notes to remember:
-
- First, remember the -p flag! It’ll keep the pipeline from overwriting the directory if it already exists in the future.
- Second, remember the name! We’re going to need it later.