Integration of FAST with Jenkins¶
The integration of FAST in CI MODE into the Jenkins workflow is configured via the Jenkinsfile
file. More details about the Jenkins workflow configuration are available in the Jenkins official documentation.
Passing FAST Node Token¶
To securely use the FAST node token, pass its value in the environment variable in your project settings.
Configured workflow
Further instructions require already configured workflow that corresponds to one of the following points:
- The test automation is implemented. In this case, the request recording and security testing steps will be added.
- The set of baseline requests is already recorded. In this case, the security testing step will be added.
Adding the Step of Request Recording¶
To implement the request recording, apply the following settings to the step of automated application testing:
-
Add the command running FAST Docker container in the
CI_MODE=recording
mode with other required variables before the command running automated tests. For example: -
Configure proxying of automated tests via FAST node. For example:
Docker Network
Before recording requests, make sure the FAST node and tool for automated testing are running on the same network.
Example of the automated testing step with running FAST node in the recording mode
stage('Run autotests with recording FAST node') {
steps {
sh label: 'create network', script: 'docker network create my-network'
sh label: 'run fast with recording', script: 'docker run --rm --name fast -d -e WALLARM_API_TOKEN=$WALLARM_API_TOKEN -e CI_MODE=recording -e WALLARM_API_HOST=us1.api.wallarm.com -p 8088:8080 --network my-network wallarm/fast'
sh label: 'run selenium', script: 'docker run --rm -d --name selenium -p 4444:4444 --network my-network -e http_proxy=\'http://fast:8080\' -e https_proxy=\'https://fast:8080\' selenium/standalone-firefox:latest'
sh label: 'run application', script: 'docker run --rm --name app-test --network my-network -e CAPYBARA_SERVER_HOST=app-test -p 3000:3000 app-test bundle exec rspec spec/features/posts_spec.rb'
sh label: 'stop selenium', script: 'docker stop selenium'
sh label: 'stop fast', script: 'docker stop fast'
sh label: 'remove network', script: 'docker network rm my-network'
}
}
An example includes the following steps:
- Create the Docker network
my-network
. - Run the FAST node in the recording mode on the network
my-network
. - Run the tool for automated testing Selenium with the FAST node as a proxy on the network
my-network
. - Run the test application and automated tests.
- Stop Selenium and FAST node.
- Delete the
my-network
network.
Adding the Step of Security Testing¶
To implement the security testing, add the corresponding separate step to your workflow following these instructions:
-
If the test application is not running, add the command to run the application.
-
Add the command running FAST Docker container in the
CI_MODE=testing
mode with other required variables after the command running the application.Using the recorded set of baseline requests
If the set of baseline requests was recorded in another pipeline, specify the record ID in the TEST_RECORD_ID variable. Otherwise, the last recorded set will be used.
Example of the command:
Docker Network
Before security testing, make sure the FAST node and test application are running on the same network.
Example of the security testing step
stage('Run security tests') {
steps {
sh label: 'create network', script: 'docker network create my-network'
sh label: 'start application', script: ' docker run --rm -d --name app-test --network my-network -e CAPYBARA_SERVER_HOST=app-test -p 3000:3000 app-test'
sh label: 'run fast in testing mode', script: 'docker run --name fast -e WALLARM_API_TOKEN=$WALLARM_API_TOKEN -e CI_MODE="testing" -e WALLARM_API_HOST="us1.api.wallarm.com" --network my-network -e TEST_RUN_URI="http://app-test:3000" --rm wallarm/fast'
sh label: 'stop application', script: ' docker stop app-test '
sh label: 'remove network', script: ' docker network rm my-network '
}
}
An example includes the following steps:
- Create the Docker network
my-network
. - Run the test application on the
my-network
network. - Run the FAST node in the testing mode on the network
my-network
. TheTEST_RECORD_ID
variable is omitted since the set of baseline requests was created in the current pipeline and is the last recorded. The FAST node will be stopped automatically when testing is finished. - Stop the test application.
- Delete the
my-network
network.
Getting the Result of Testing¶
The result of security testing will be displayed on the Jenkins interface.
More Examples¶
You can find examples of integrating FAST to the Jenkins workflow on our GitHub.
Further questions
If you have questions related to FAST integration, please contact us.